Fix handling of team sync when a user already exists with the email address

This commit is contained in:
Joseph Schorr 2017-04-25 17:42:35 -04:00
parent 1ca51146e7
commit 36f2272fe2
3 changed files with 56 additions and 6 deletions

View file

@ -107,11 +107,15 @@ class FederatedUsers(object):
return (None, 'Unable to pick a username. Please report this to your administrator.')
prompts = model.user.get_default_user_prompts(features)
db_user = model.user.create_federated_user(valid_username, email, self._federated_service,
username,
set_password_notification=False,
email_required=self._requires_email,
prompts=prompts)
try:
db_user = model.user.create_federated_user(valid_username, email, self._federated_service,
username,
set_password_notification=False,
email_required=self._requires_email,
prompts=prompts)
except model.InvalidEmailAddressException as iae:
return (None, iae.message)
else:
# Update the db attributes from the federated service.
if email and db_user.email != email: