Fix OAuth login to try usernames until it finds a valid username

This commit is contained in:
Joseph Schorr 2014-11-10 11:30:47 -05:00
parent 8548538516
commit a1147236ea

View file

@ -84,8 +84,15 @@ def conduct_oauth_login(service, user_id, username, email, metadata={}):
# Try to create the user
try:
valid = next(generate_valid_usernames(username))
to_login = model.create_federated_user(valid, email, service_name.lower(),
new_username = None
for valid in generate_valid_usernames(username):
if model.get_user_or_org(valid):
continue
new_username = valid
break
to_login = model.create_federated_user(new_username, email, service_name.lower(),
user_id, set_password_notification=True,
metadata=metadata)