Skip to content

Commit

Permalink
Invalidate email confirmation on password change
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed May 9, 2024
1 parent 45e7f16 commit df24c66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/routers/passwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ router.post('/passwd', auth, express.json(), async (req, res, next)=>{
return res.status(400).send('new_pass must be at least 6 characters long.')
else{
await db.write(
'UPDATE user SET password=?, `pass_recovery_token` = NULL WHERE `id` = ?',
'UPDATE user SET password=?, `pass_recovery_token` = NULL, `change_email_confirm_token` = NULL WHERE `id` = ?',
[await bcrypt.hash(req.body.new_pass, 8), req.user.id]
);
invalidate_cached_user(req.user);
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/routers/set-pass-using-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ router.post('/set-pass-using-token', express.json(), async (req, res, next)=>{

try{
const info = await db.write(
'UPDATE user SET password=?, pass_recovery_token=NULL WHERE `uuid` = ? AND pass_recovery_token = ?',
'UPDATE user SET password=?, pass_recovery_token=NULL, change_email_confirm_token=NULL WHERE `uuid` = ? AND pass_recovery_token = ?',
[await bcrypt.hash(req.body.password, 8), user_uid, token],
);

Expand Down

0 comments on commit df24c66

Please sign in to comment.