Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashmini committed Oct 5, 2023
1 parent 662aaf0 commit 7d6d0fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,8 @@ public Response validateCodePost(CodeValidationRequestDTO codeValidationRequestD
try {
NotificationPasswordRecoveryManager notificationPasswordRecoveryManager = RecoveryUtil
.getNotificationBasedPwdRecoveryManager();
String code = codeValidationRequestDTO.getCode();
try {
String hashedCode = Utils.doHash(code);
user = notificationPasswordRecoveryManager
.getValidatedUser(hashedCode, codeValidationRequestDTO.getStep());
} catch (UserStoreException e) {
throw Utils.handleServerException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_NO_HASHING_ALGO_FOR_CODE, null);
} catch (IdentityRecoveryException e) {
user = notificationPasswordRecoveryManager
.getValidatedUser(code, codeValidationRequestDTO.getStep());
}
user = notificationPasswordRecoveryManager
.getValidatedUser(codeValidationRequestDTO.getCode(), codeValidationRequestDTO.getStep());
} catch (IdentityRecoveryClientException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Client Error while validating the confirmation code ", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,16 @@ public void validateConfirmationCode(String code, String recoveryStep) throws Id
public User getValidatedUser(String code, String recoveryStep) throws IdentityRecoveryException {

UserRecoveryDataStore userRecoveryDataStore = JDBCRecoveryDataStore.getInstance();
UserRecoveryData userRecoveryData = userRecoveryDataStore.load(code);
UserRecoveryData userRecoveryData;
try {
String hashedCode = Utils.doHash(code);
userRecoveryData = userRecoveryDataStore.load(hashedCode);
} catch (UserStoreException e) {
throw Utils.handleServerException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_NO_HASHING_ALGO_FOR_CODE, null);
} catch (IdentityRecoveryException e) {
userRecoveryData = userRecoveryDataStore.load(code);
}
String contextTenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String userTenantDomain = userRecoveryData.getUser().getTenantDomain();
if (!StringUtils.equals(contextTenantDomain, userTenantDomain)) {
Expand Down

0 comments on commit 7d6d0fd

Please sign in to comment.