Added a way for admins to reset passwords.
This commit is contained in:
parent
5742a1d33d
commit
b7584de440
1 changed files with 85 additions and 67 deletions
18
forum.nim
18
forum.nim
|
|
@ -524,6 +524,12 @@ proc setBan(c: var TForumData, nick, reason: string): bool =
|
||||||
sql("update person set ban = ? where name = ?")
|
sql("update person set ban = ? where name = ?")
|
||||||
return tryExec(db, query, reason, nick)
|
return tryExec(db, query, reason, nick)
|
||||||
|
|
||||||
|
proc setPassword(c: var TForumData, nick, pass: string): bool =
|
||||||
|
const query =
|
||||||
|
sql("update person set password = ?, salt = ? where name = ?")
|
||||||
|
var salt = makeSalt()
|
||||||
|
result = tryExec(db, query, makePassword(pass, salt), salt, nick)
|
||||||
|
|
||||||
proc hasReplyBtn(c: var TForumData): bool =
|
proc hasReplyBtn(c: var TForumData): bool =
|
||||||
result = c.req.pathInfo != "/donewthread" and c.req.pathInfo != "/doreply"
|
result = c.req.pathInfo != "/donewthread" and c.req.pathInfo != "/doreply"
|
||||||
result = result and c.req.params["action"] != "reply"
|
result = result and c.req.params["action"] != "reply"
|
||||||
|
|
@ -1042,6 +1048,18 @@ routes:
|
||||||
resp genMain(c, "Failed to change the ban status of user.",
|
resp genMain(c, "Failed to change the ban status of user.",
|
||||||
"Error - Nim Forum")
|
"Error - Nim Forum")
|
||||||
|
|
||||||
|
get "/setpassword/?":
|
||||||
|
createTFD()
|
||||||
|
cond (@"nick" != "")
|
||||||
|
cond (@"pass" != "")
|
||||||
|
if not c.isAdmin:
|
||||||
|
resp genMain(c, "You cannot change this user's pass.", "Error - Nim Forum")
|
||||||
|
let res = setPassword(c, @"nick", @"pass")
|
||||||
|
if res:
|
||||||
|
resp genMain(c, "Success", "Nim Forum")
|
||||||
|
else:
|
||||||
|
resp genMain(c, "Failure", "Nim Forum")
|
||||||
|
|
||||||
const licenseRst = slurp("static/license.rst")
|
const licenseRst = slurp("static/license.rst")
|
||||||
get "/license":
|
get "/license":
|
||||||
createTFD()
|
createTFD()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue