diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/handler/UserSelfRegistrationHandler.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/handler/UserSelfRegistrationHandler.java index 0f9c11396..fa302505e 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/handler/UserSelfRegistrationHandler.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/handler/UserSelfRegistrationHandler.java @@ -122,33 +122,6 @@ public void handleEvent(Event event) throws IdentityEventException { if (IdentityEventConstants.Event.POST_ADD_USER.equals(event.getEventName())) { UserRecoveryDataStore userRecoveryDataStore = JDBCRecoveryDataStore.getInstance(); - if (isAccountLockOnCreation || isEnableConfirmationOnCreation) { - HashMap userClaims = new HashMap<>(); - if (isAccountLockOnCreation) { - // Need to lock user account. - userClaims.put(IdentityRecoveryConstants.ACCOUNT_LOCKED_CLAIM, Boolean.TRUE.toString()); - userClaims.put(IdentityRecoveryConstants.ACCOUNT_LOCKED_REASON_CLAIM, - IdentityMgtConstants.LockedReason.PENDING_SELF_REGISTRATION.toString()); - } - if (Utils.isAccountStateClaimExisting(tenantDomain)) { - userClaims.put(IdentityRecoveryConstants.ACCOUNT_STATE_CLAIM_URI, - IdentityRecoveryConstants.PENDING_SELF_REGISTRATION); - } - try { - userStoreManager.setUserClaimValues(user.getUserName(), userClaims, null); - if (log.isDebugEnabled()) { - if (isAccountLockOnCreation) { - log.debug("Locked user account: " + user.getUserName()); - } - if (isEnableConfirmationOnCreation) { - log.debug("Send verification notification for user account: " + user.getUserName()); - } - } - } catch (UserStoreException e) { - throw new IdentityEventException("Error while lock user account :" + user.getUserName(), e); - } - } - try { // Get the user preferred notification channel. String preferredChannel = resolveNotificationChannel(eventProperties, userName, tenantDomain, @@ -162,6 +135,34 @@ public void handleEvent(Event event) throws IdentityEventException { return; } + // If account lock on creation is enabled, lock the account by persisting the account lock claim. + if (isAccountLockOnCreation || isEnableConfirmationOnCreation) { + HashMap userClaims = new HashMap<>(); + if (isAccountLockOnCreation) { + // Need to lock user account. + userClaims.put(IdentityRecoveryConstants.ACCOUNT_LOCKED_CLAIM, Boolean.TRUE.toString()); + userClaims.put(IdentityRecoveryConstants.ACCOUNT_LOCKED_REASON_CLAIM, + IdentityMgtConstants.LockedReason.PENDING_SELF_REGISTRATION.toString()); + } + if (Utils.isAccountStateClaimExisting(tenantDomain)) { + userClaims.put(IdentityRecoveryConstants.ACCOUNT_STATE_CLAIM_URI, + IdentityRecoveryConstants.PENDING_SELF_REGISTRATION); + } + try { + userStoreManager.setUserClaimValues(user.getUserName(), userClaims, null); + if (log.isDebugEnabled()) { + if (isAccountLockOnCreation) { + log.debug("Locked user account: " + user.getUserName()); + } + if (isEnableConfirmationOnCreation) { + log.debug("Send verification notification for user account: " + user.getUserName()); + } + } + } catch (UserStoreException e) { + throw new IdentityEventException("Error while lock user account :" + user.getUserName(), e); + } + } + boolean isSelfRegistrationConfirmationNotify = Boolean.parseBoolean(Utils.getSignUpConfigs (IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_NOTIFY_ACCOUNT_CONFIRMATION, user.getTenantDomain()));