Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix field name of reset password token, add verifier and set status #161

Closed
wants to merge 8 commits into from
7 changes: 3 additions & 4 deletions api/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,19 +447,18 @@ async function storePassword(req, res) {
userId: userid,
status: false,
}).exec();
if (!resetPassword) {
const expireTime = moment.utc(resetPassword.resetPasswordExpires).isBefore(moment());
tomivm marked this conversation as resolved.
Show resolved Hide resolved
tomivm marked this conversation as resolved.
Show resolved Hide resolved
if (expireTime) {
return res.status(500).json({
message: 'Expired time to reset password! ',
error: err.message,
error: 'Expired time to reset password! ',
});
}
// the token and the hashed token in the db are verified before updating the password
bcrypt.compare(
token,
resetPassword.resetPasswordToken,
function (errBcrypt, resBcrypt) {
let expireTime = moment.utc(resetPassword.expire); // expireTime and currentTime is never used
let currentTime = new Date();
if (!resBcrypt) {
return res.status(500).json({
message: 'Error resetting user password.',
Expand Down