Skip to content

Commit

Permalink
fix(rest.identity): fixed passswordAuthEnabled property [backport rel…
Browse files Browse the repository at this point in the history
…ease-5.4.0] (#5021)

fix(rest.identity): fixed passswordAuthEnabled property (#5020)

(cherry picked from commit 14e1b7c)

Co-authored-by: sfiorani <[email protected]>
  • Loading branch information
github-actions[bot] and sfiorani authored Nov 24, 2023
1 parent f69f68a commit f2b7cc1
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class IdentityService {
private static final String USER_ROLE_NAME_PREFIX = "kura.user.";

private static final String KURA_NEED_PASSWORD_CHANGE_PROPERTY = "kura.need.password.change";
private static final String PASSWORD_PROPERTY = "kura.password";

private final UserAdminHelper userAdminHelper;
private final ConfigurationService configurationService;
Expand Down Expand Up @@ -112,8 +113,7 @@ public Set<UserDTO> getUserConfig() {

private UserDTO initUserConfig(final User user) {

final boolean isPasswordEnabled = user.getCredentials()
.get(KURA_NEED_PASSWORD_CHANGE_PROPERTY) instanceof String;
final boolean isPasswordEnabled = user.getCredentials().get(PASSWORD_PROPERTY) instanceof String;
final boolean isPasswordChangeRequired = Objects.equals("true",
user.getProperties().get(KURA_NEED_PASSWORD_CHANGE_PROPERTY));

Expand Down Expand Up @@ -201,13 +201,13 @@ private void updatePasswordOptions(UserDTO userDTO, final Dictionary<String, Obj
if (password != null) {
validateUserPassword(password);
try {
credentials.put(KURA_NEED_PASSWORD_CHANGE_PROPERTY, this.cryptoService.sha256Hash(password));
credentials.put(PASSWORD_PROPERTY, this.cryptoService.sha256Hash(password));
} catch (final Exception e) {
throw new KuraException(KuraErrorCode.SERVICE_UNAVAILABLE, e);
}
}
} else {
credentials.remove(KURA_NEED_PASSWORD_CHANGE_PROPERTY);
credentials.remove(PASSWORD_PROPERTY);
}
}

Expand Down

0 comments on commit f2b7cc1

Please sign in to comment.