@@ -135,6 +135,34 @@ public void handleEvent(Event event) throws IdentityEventException {
135
135
return ;
136
136
}
137
137
138
+ // If account lock on creation is enabled, lock the account by persisting the account lock claim.
139
+ if (isAccountLockOnCreation || isEnableConfirmationOnCreation ) {
140
+ HashMap <String , String > userClaims = new HashMap <>();
141
+ if (isAccountLockOnCreation ) {
142
+ // Need to lock user account.
143
+ userClaims .put (IdentityRecoveryConstants .ACCOUNT_LOCKED_CLAIM , Boolean .TRUE .toString ());
144
+ userClaims .put (IdentityRecoveryConstants .ACCOUNT_LOCKED_REASON_CLAIM ,
145
+ IdentityMgtConstants .LockedReason .PENDING_SELF_REGISTRATION .toString ());
146
+ }
147
+ if (Utils .isAccountStateClaimExisting (tenantDomain )) {
148
+ userClaims .put (IdentityRecoveryConstants .ACCOUNT_STATE_CLAIM_URI ,
149
+ IdentityRecoveryConstants .PENDING_SELF_REGISTRATION );
150
+ }
151
+ try {
152
+ userStoreManager .setUserClaimValues (user .getUserName (), userClaims , null );
153
+ if (log .isDebugEnabled ()) {
154
+ if (isAccountLockOnCreation ) {
155
+ log .debug ("Locked user account: " + user .getUserName ());
156
+ }
157
+ if (isEnableConfirmationOnCreation ) {
158
+ log .debug ("Send verification notification for user account: " + user .getUserName ());
159
+ }
160
+ }
161
+ } catch (UserStoreException e ) {
162
+ throw new IdentityEventException ("Error while lock user account :" + user .getUserName (), e );
163
+ }
164
+ }
165
+
138
166
boolean isSelfRegistrationConfirmationNotify = Boolean .parseBoolean (Utils .getSignUpConfigs
139
167
(IdentityRecoveryConstants .ConnectorConfig .SELF_REGISTRATION_NOTIFY_ACCOUNT_CONFIRMATION , user .getTenantDomain ()));
140
168
@@ -166,33 +194,6 @@ public void handleEvent(Event event) throws IdentityEventException {
166
194
} catch (IdentityRecoveryException e ) {
167
195
throw new IdentityEventException ("Error while sending self sign up notification " , e );
168
196
}
169
- if (isAccountLockOnCreation || isEnableConfirmationOnCreation ) {
170
- HashMap <String , String > userClaims = new HashMap <>();
171
- if (isAccountLockOnCreation ) {
172
- // Need to lock user account.
173
- userClaims .put (IdentityRecoveryConstants .ACCOUNT_LOCKED_CLAIM , Boolean .TRUE .toString ());
174
- userClaims .put (IdentityRecoveryConstants .ACCOUNT_LOCKED_REASON_CLAIM ,
175
- IdentityMgtConstants .LockedReason .PENDING_SELF_REGISTRATION .toString ());
176
- }
177
- if (Utils .isAccountStateClaimExisting (tenantDomain )) {
178
- userClaims .put (IdentityRecoveryConstants .ACCOUNT_STATE_CLAIM_URI ,
179
- IdentityRecoveryConstants .PENDING_SELF_REGISTRATION );
180
- }
181
- try {
182
- userStoreManager .setUserClaimValues (user .getUserName (), userClaims , null );
183
- if (log .isDebugEnabled ()) {
184
- if (isAccountLockOnCreation ) {
185
- log .debug ("Locked user account: " + user .getUserName ());
186
- }
187
- if (isEnableConfirmationOnCreation ) {
188
- log .debug ("Send verification notification for user account: " + user .getUserName ());
189
- }
190
- }
191
- } catch (UserStoreException e ) {
192
- throw new IdentityEventException ("Error while lock user account :" + user .getUserName (), e );
193
- }
194
- }
195
-
196
197
}
197
198
}
198
199
0 commit comments