@@ -49,6 +49,9 @@ def get_identity_templates(auth_user):
4949 context ["unconfigured_identity_template" ] = []
5050 all_modules = helper .get_available_access_modules ()
5151 for user_identity in user_identities :
52+ if not all_modules [user_identity .access_tag ].get_identity_template ():
53+ all_modules .pop (user_identity .access_tag )
54+ continue
5255 is_identity_configured = _is_valid_identity_json (
5356 identity = user_identity .identity
5457 )
@@ -63,6 +66,11 @@ def get_identity_templates(auth_user):
6366 all_modules .pop (user_identity .access_tag )
6467
6568 for mod in all_modules .values ():
69+ if not mod .get_identity_template ():
70+ auth_user .user .create_new_identity (
71+ access_tag = mod .tag (), identity = {}
72+ )
73+ continue
6674 context ["unconfigured_identity_template" ].append (
6775 {
6876 "accessUserTemplatePath" : mod .get_identity_template (),
@@ -94,12 +102,12 @@ def create_identity(user_identity_form, auth_user):
94102 existing_user_identity = user .get_active_identity (
95103 access_tag = selected_access_module .tag ()
96104 )
97- if new_module_identity_json == existing_user_identity .identity :
98- raise IdentityNotChangedException ()
99105 existing_user_access_mapping = None
100106
101107 # get useraccess if an identity already exists
102108 if existing_user_identity :
109+ if new_module_identity_json == existing_user_identity .identity :
110+ raise IdentityNotChangedException ()
103111 existing_user_access_mapping = (
104112 existing_user_identity .get_active_access_mapping ()
105113 )
@@ -142,19 +150,20 @@ def __change_identity_and_transfer_access_mapping(
142150 )
143151 # replicate the memberships with new identity
144152 new_user_access_mapping = []
145- if existing_user_access_mapping :
146- new_user_access_mapping = (
147- new_user_identity .replicate_active_access_membership_for_module (
148- existing_access = existing_user_access_mapping
153+ if existing_user_identity :
154+ if existing_user_access_mapping :
155+ new_user_access_mapping = (
156+ new_user_identity .replicate_active_access_membership_for_module (
157+ existing_access = existing_user_access_mapping
158+ )
149159 )
150- )
151- system_user = User .get_system_user ()
160+ system_user = User .get_system_user ()
152161
153- for mapping in existing_user_access_mapping :
154- if mapping .is_approved ():
155- revoke_request (user_access_mapping = mapping , revoker = system_user )
162+ for mapping in existing_user_access_mapping :
163+ if mapping .is_approved ():
164+ revoke_request (user_access_mapping = mapping , revoker = system_user )
156165
157- existing_user_identity .decline_all_non_approved_access_mappings ("Identity Updated" )
166+ existing_user_identity .decline_all_non_approved_access_mappings ("Identity Updated" )
158167
159168 for mapping in new_user_access_mapping :
160169 if mapping .is_processing () or mapping .is_grantfailed ():
0 commit comments