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

Bug Fix: Email update if username (@ based) is diff from email on UMAPI #576

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion user_sync/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,14 +839,21 @@ def update_umapi_user(self, umapi_info, user_key, umapi_connector,

# if user has email-type username and it is different from email address, then we need to
# override the username with email address
if '@' in directory_user['username'] and directory_user['email'] != directory_user['username']:
if '@' in directory_user['username'] and normalize_string(directory_user['email']) != normalize_string(directory_user['username']):
if groups_to_add or groups_to_remove or attributes_to_update:
directory_user['username'] = directory_user['email']
if attributes_to_update and 'email' in attributes_to_update:
directory_user['email'] = umapi_user['email']
attributes_to_update['username'] = umapi_user['username']
directory_user['username'] = umapi_user['email']

# if email based username on umapi is differ than email on umapi and need to update email, then we need to
# override the username with email address
if '@' in umapi_user['username'] and normalize_string(umapi_user['username']) != normalize_string(umapi_user['email']):
if attributes_to_update and 'email' in attributes_to_update:
directory_user['email'] = umapi_user['email']
directory_user['username'] = umapi_user['email']

self.post_sync_data.update_umapi_data(umapi_info.name, user_key, groups_to_add, groups_to_remove,
**attributes_to_update)
commands = user_sync.connector.umapi.Commands(identity_type, directory_user['email'],
Expand Down