Skip to content

Commit

Permalink
Fix false-positive password recovery response
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Apr 21, 2024
1 parent f5f75db commit 5c1e6ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/backend/src/routers/set-pass-using-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ router.post('/set-pass-using-token', express.json(), async (req, res, next)=>{
return res.status(400).send(`Password must be at least ${config.min_pass_length} characters long.`)

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

if ( ! info?.anyRowsAffected ) {
return res.status(400).send('Invalid token or user_id.');
}

invalidate_cached_user_by_id(req.body.user_id);

return res.send('Password successfully updated.')
Expand Down

0 comments on commit 5c1e6ab

Please sign in to comment.