Skip to content

Commit

Permalink
TRUNK-6147 - Secret question/answer are unusable after password change (
Browse files Browse the repository at this point in the history
  • Loading branch information
mseaton committed Nov 2, 2022
1 parent 1bd2dc3 commit 77a44b4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ public void changePassword(User u, String pw) throws DAOException {
}

log.debug("updating password");
//update the user with the new password
String salt = Security.getRandomToken();
String salt = getLoginCredential(u).getSalt();
if (StringUtils.isBlank(salt)) {
salt = Security.getRandomToken();
}
String newHashedPassword = Security.encodeString(pw + salt);

updateUserPassword(newHashedPassword, salt, authUser.getUserId(), new Date(), u.getUserId());
Expand Down Expand Up @@ -363,7 +365,7 @@ public void changePassword(String pw, String pw2) throws DAOException {
log.info("updating password for {}", u.getUsername());

// update the user with the new password
String salt = Security.getRandomToken();
String salt = credentials.getSalt();
String newHashedPassword = Security.encodeString(pw2 + salt);
updateUserPassword(newHashedPassword, salt, u.getUserId(), new Date(), u.getUserId());
}
Expand Down

0 comments on commit 77a44b4

Please sign in to comment.