Skip to content

Commit

Permalink
Check if the password changed when user is not null
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Oct 21, 2023
1 parent 9b599cc commit 87b2e45
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ let needSetup = false;
decoded.username,
]);

// Check if the password changed
if (decoded.h !== shake256(user.password, SHAKE256_LENGTH)) {
throw new Error("The token is invalid due to password change or old token");
}

if (user) {
// Check if the password changed
if (decoded.h !== shake256(user.password, SHAKE256_LENGTH)) {
throw new Error("The token is invalid due to password change or old token");
}

log.debug("auth", "afterLogin");
afterLogin(socket, user);
log.debug("auth", "afterLogin ok");
Expand Down

0 comments on commit 87b2e45

Please sign in to comment.