Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip triggering email/mobile verification during email OTP/SMS OTP flows #795

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,12 @@ public enum SkipEmailVerificationOnUpdateStates {

/* State maintained to skip triggering an email verification when the update request contains other claims
without the email address claim. */
SKIP_ON_INAPPLICABLE_CLAIMS
SKIP_ON_INAPPLICABLE_CLAIMS,

/* State maintained to skip triggering an email verification, when the email address was updated by user during
the Email OTP flow at the first login where the email address is not previously set. At the moment email
address was already verified during the email OTP verification. So no need to verify it again. */
SKIP_ON_EMAIL_OTP_FLOW
}

/**
Expand Down Expand Up @@ -946,6 +951,11 @@ public enum SkipMobileNumberVerificationOnUpdateStates {

/* State maintained to skip triggering an SMS OTP verification when the update request contains other claims
without the mobile number claim. */
SKIP_ON_INAPPLICABLE_CLAIMS
SKIP_ON_INAPPLICABLE_CLAIMS,

/* State maintained to skip triggering an SMS OTP verification, when the mobile number was updated by user
during the SMS OTP flow at the first login where the mobile number is not previously set. At the moment mobile
number was already verified during the SMS OTP verification. So no need to verify it again. */
SKIP_ON_SMS_OTP_FLOW
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ private void preSetUserClaimOnMobileNumberUpdate(Map<String, String> claims, Use
return;
}

/*
Within the SMS OTP flow, the mobile number is updated in the user profile after successfully verifying the
OTP. Therefore, the mobile number is already verified & no need to verify it again.
*/
if (IdentityRecoveryConstants.SkipMobileNumberVerificationOnUpdateStates.SKIP_ON_SMS_OTP_FLOW.toString().equals
(Utils.getThreadLocalToSkipSendingSmsOtpVerificationOnUpdate())) {
invalidatePendingMobileVerification(user, userStoreManager, claims);
return;
}

if (Utils.getThreadLocalToSkipSendingSmsOtpVerificationOnUpdate() != null) {
Utils.unsetThreadLocalToSkipSendingSmsOtpVerificationOnUpdate();
}
Expand Down Expand Up @@ -317,7 +327,9 @@ private void postSetUserClaimOnMobileNumberUpdate(User user, UserStoreManager us
SkipMobileNumberVerificationOnUpdateStates.SKIP_ON_EXISTING_MOBILE_NUM.toString().equals
(skipMobileNumVerificationOnUpdateState) && !IdentityRecoveryConstants
.SkipMobileNumberVerificationOnUpdateStates.SKIP_ON_INAPPLICABLE_CLAIMS.toString().equals
(skipMobileNumVerificationOnUpdateState)) {
(skipMobileNumVerificationOnUpdateState) && !IdentityRecoveryConstants
.SkipMobileNumberVerificationOnUpdateStates.SKIP_ON_SMS_OTP_FLOW.toString().equals
(skipMobileNumVerificationOnUpdateState)) {

String verificationPendingMobileNumClaim = getVerificationPendingMobileNumValue(userStoreManager, user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,16 @@ private void preSetUserClaimsOnEmailUpdate(Map<String, String> claims, UserStore
return;
}

/*
Within the Email OTP flow, the email address is updated in the user profile after successfully verifying the
OTP. Therefore, the email is already verified & no need to verify it again.
*/
if (IdentityRecoveryConstants.SkipEmailVerificationOnUpdateStates.SKIP_ON_EMAIL_OTP_FLOW.toString().equals
(Utils.getThreadLocalToSkipSendingEmailVerificationOnUpdate())) {
invalidatePendingEmailVerification(user, userStoreManager, claims);
return;
}

if (Utils.getThreadLocalToSkipSendingEmailVerificationOnUpdate() != null) {
Utils.unsetThreadLocalToSkipSendingEmailVerificationOnUpdate();
}
Expand Down Expand Up @@ -541,7 +551,9 @@ private void postSetUserClaimsOnEmailUpdate(User user, UserStoreManager userStor
SkipEmailVerificationOnUpdateStates.SKIP_ON_EXISTING_EMAIL.toString().equals
(skipEmailVerificationOnUpdateState) && !IdentityRecoveryConstants
.SkipEmailVerificationOnUpdateStates.SKIP_ON_INAPPLICABLE_CLAIMS.toString().equals
(skipEmailVerificationOnUpdateState)) {
(skipEmailVerificationOnUpdateState) && !IdentityRecoveryConstants
.SkipEmailVerificationOnUpdateStates.SKIP_ON_EMAIL_OTP_FLOW.toString().equals
(skipEmailVerificationOnUpdateState)) {

String pendingVerificationEmailClaimValue = getPendingVerificationEmailValue(userStoreManager, user);

Expand Down
Loading