use of org.molgenis.security.twofactor.exceptions.InvalidVerificationCodeException in project molgenis by molgenis.
the class TwoFactorAuthenticationServiceImpl method isVerificationCodeValidForUser.
@Override
public boolean isVerificationCodeValidForUser(String verificationCode) {
boolean isValid = false;
UserSecret userSecret = getSecret();
if (!userIsBlocked()) {
try {
if (otpService.tryVerificationCode(verificationCode, userSecret.getSecret())) {
isValid = true;
updateFailedLoginAttempts(0);
}
} catch (InvalidVerificationCodeException err) {
updateFailedLoginAttempts(userSecret.getFailedLoginAttempts() + FAILED_LOGIN_ATTEMPT_ITERATION);
if (!userIsBlocked()) {
throw err;
}
}
}
return isValid;
}
Aggregations