reset password complete

This commit is contained in:
Alessandro Ferro
2024-03-26 17:05:17 +01:00
parent 9561b874a2
commit 68dafe32d1
3 changed files with 113 additions and 11 deletions

View File

@ -48,7 +48,7 @@ async function resetPassword(password, secret) {
// Delete all the requests associated with that e-mail
await tr('RequestResetPassword').where({
email
email: request.email
}).del();
});
}

View File

@ -44,8 +44,8 @@ async function reset(req, res) {
const diffMilliseconds = Date.now() - requester.time_of_request.getTime();
// Check whether the request was not performed more than 30 minutes ago
if (diffMilliseconds / (1000 * 60) <= 30) {
const newPassword = await bcrypt.hash(req.body.password, 10);
ResetPassword.resetPassword(newPassword, req.body.secret);
const newPassword = await bcrypt.hash(req.body.password.trim(), 10);
await ResetPassword.resetPassword(newPassword, req.body.secret);
return res.status(204).send();
}
}