Add template for database update script, work on password recovery
This commit is contained in:
parent
8b0c370ad0
commit
447a70be98
3 changed files with 65 additions and 2 deletions
|
|
@ -609,7 +609,30 @@ function handlePasswordRecover(req, res) {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO actual reset
|
||||
var newpw = "";
|
||||
const avail = "abcdefgihkmnpqrstuvwxyz0123456789";
|
||||
for (var i = 0; i < 10; i++) {
|
||||
newpw += avail[Math.floor(Math.random() * avail.length)];
|
||||
}
|
||||
db.users.setPassword(row.name, newpw, function (err) {
|
||||
if (err) {
|
||||
sendJade(req, "account-passwordrecover", {
|
||||
recovered: false,
|
||||
recoverErr: "Database error. Please contact an administrator if " +
|
||||
"this persists.",
|
||||
loginName: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
db.deletePasswordReset(hash);
|
||||
|
||||
sendJade(req, "account-passwordrecover", {
|
||||
recovered: true,
|
||||
recoverPw: newpw,
|
||||
loginName: false
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue