Skip to content

Commit

Permalink
Corrected otp freezing property names
Browse files Browse the repository at this point in the history
Signed-off-by: Loganathan Sekar <[email protected]>
  • Loading branch information
Loganathan Sekar authored and Loganathan Sekar committed Feb 7, 2024
1 parent 4a1d1db commit 5a3db6c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public class OTPManager {
@Autowired
private NotificationService notificationService;

@Value("${mosip.ida.otp.validation-attempt-threshold:5}")
@Value("${mosip.ida.otp.validation.attempt.count.threshold:5}")
private int numberOfValidationAttemptsAllowed;

@Value("${mosip.ida.otp.frozen.time.minutes:30}")
@Value("${mosip.ida.otp.frozen.duration.minutes:30}")
private int otpFrozenTimeMinutes;

/** The logger. */
Expand Down Expand Up @@ -207,13 +207,12 @@ public boolean validateOtp(String pinValue, String otpKey, String individualId)
}
}

// Increment the validation attempt count.
int attemptCount = otpEntity.getValidationRetryCount() == null ? 1 : otpEntity.getValidationRetryCount() + 1;

//Optional<OtpTransaction> otpTxnOpt = otpRepo.findByOtpHashAndStatusCode(otpHash, IdAuthCommonConstants.ACTIVE_STATUS);
if(otpEntity.getStatusCode().equals(IdAuthCommonConstants.ACTIVE_STATUS)) {
String otpHash = getOtpHash(pinValue, otpKey);
if (otpEntity.getOtpHash().equals(otpHash)) {
//OtpTransaction otpTxn = otpRepo.findByOtpHashAndStatusCode(otpHash, IdAuthCommonConstants.ACTIVE_STATUS);
otpEntity.setUpdDTimes(DateUtils.getUTCCurrentDateTime());
otpEntity.setStatusCode(IdAuthCommonConstants.USED_STATUS);
otpRepo.save(otpEntity);
Expand All @@ -225,7 +224,7 @@ public boolean validateOtp(String pinValue, String otpKey, String individualId)
throw new IdAuthenticationBusinessException(IdAuthenticationErrorConstants.EXPIRED_OTP);
}
} else {
// This condition increases the validation attempt count.
//Set the incremented validation attempt count
otpEntity.setValidationRetryCount(attemptCount);
if (attemptCount >= numberOfValidationAttemptsAllowed) {
otpEntity.setStatusCode(IdAuthCommonConstants.FROZEN);
Expand Down

0 comments on commit 5a3db6c

Please sign in to comment.