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; }