Skip to content

Commit 82a4d29

Browse files
Merge pull request #576 from bhunut-adobe/bugfix/update-email
Bug Fix: Email update if username (@ based) is diff from email on UMAPI
2 parents 61f21fd + 3f00334 commit 82a4d29

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

user_sync/rules.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,14 +839,21 @@ def update_umapi_user(self, umapi_info, user_key, umapi_connector,
839839

840840
# if user has email-type username and it is different from email address, then we need to
841841
# override the username with email address
842-
if '@' in directory_user['username'] and directory_user['email'] != directory_user['username']:
842+
if '@' in directory_user['username'] and normalize_string(directory_user['email']) != normalize_string(directory_user['username']):
843843
if groups_to_add or groups_to_remove or attributes_to_update:
844844
directory_user['username'] = directory_user['email']
845845
if attributes_to_update and 'email' in attributes_to_update:
846846
directory_user['email'] = umapi_user['email']
847847
attributes_to_update['username'] = umapi_user['username']
848848
directory_user['username'] = umapi_user['email']
849849

850+
# if email based username on umapi is differ than email on umapi and need to update email, then we need to
851+
# override the username with email address
852+
if '@' in umapi_user['username'] and normalize_string(umapi_user['username']) != normalize_string(umapi_user['email']):
853+
if attributes_to_update and 'email' in attributes_to_update:
854+
directory_user['email'] = umapi_user['email']
855+
directory_user['username'] = umapi_user['email']
856+
850857
self.post_sync_data.update_umapi_data(umapi_info.name, user_key, groups_to_add, groups_to_remove,
851858
**attributes_to_update)
852859
commands = user_sync.connector.umapi.Commands(identity_type, directory_user['email'],

0 commit comments

Comments
 (0)