From 584c77175f65f6c80f50e984965e57fbff908d5b Mon Sep 17 00:00:00 2001 From: sumedhe Date: Tue, 12 Jul 2022 10:09:01 +0530 Subject: [PATCH] Check user existence before checking the email otp is disabled for the user --- .../authenticator/emailotp/EmailOTPAuthenticator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/component/authenticator/src/main/java/org/wso2/carbon/identity/authenticator/emailotp/EmailOTPAuthenticator.java b/component/authenticator/src/main/java/org/wso2/carbon/identity/authenticator/emailotp/EmailOTPAuthenticator.java index a57d40ea..6b223c46 100755 --- a/component/authenticator/src/main/java/org/wso2/carbon/identity/authenticator/emailotp/EmailOTPAuthenticator.java +++ b/component/authenticator/src/main/java/org/wso2/carbon/identity/authenticator/emailotp/EmailOTPAuthenticator.java @@ -2630,8 +2630,14 @@ private void publishPostEmailOTPGeneratedEvent(HttpServletRequest request, Authe AuthenticatedUser authenticatedUser = (AuthenticatedUser) context.getProperty(EmailOTPAuthenticatorConstants .AUTHENTICATED_USER); Map emailOTPParameters = getAuthenticatorConfig().getParameterMap(); - if (isEmailOTPDisableForUser(authenticatedUser.getAuthenticatedSubjectIdentifier(), - context, emailOTPParameters)) { + String username = authenticatedUser.getAuthenticatedSubjectIdentifier(); + boolean isUserExist; + try { + isUserExist = FederatedAuthenticatorUtil.isUserExistInUserStore(username); + } catch (UserStoreException e) { + throw new AuthenticationFailedException("Failed to get the user from user store.", e); + } + if (isUserExist && isEmailOTPDisableForUser(username, context, emailOTPParameters)) { // Email OTP is disabled for the user. Hence not going to trigger the event. return; }