Skip to content

Commit

Permalink
fix: should autogenerate username in tpa pipeline if feature is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
syedsajjadkazmii committed Jul 9, 2024
1 parent 3e09001 commit 9ec7164
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions common/djangoapps/third_party_auth/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def B(*args, **kwargs):
from openedx.core.djangoapps.user_api import accounts
from openedx.core.djangoapps.user_api.accounts.utils import username_suffix_generator
from openedx.core.djangoapps.user_authn import cookies as user_authn_cookies
from openedx.core.djangoapps.user_authn.toggles import is_auto_generated_username_enabled
from openedx.core.djangoapps.user_authn.utils import is_safe_login_or_logout_redirect
from openedx.core.djangoapps.user_authn.views.utils import get_auto_generated_username
from common.djangoapps.third_party_auth.utils import (
get_associated_user_by_email_response,
get_user_from_email,
Expand Down Expand Up @@ -991,12 +993,15 @@ def get_username(strategy, details, backend, user=None, *args, **kwargs): # lin
else:
slug_func = lambda val: val

if email_as_username and details.get('email'):
username = details['email']
elif details.get('username'):
username = details['username']
if is_auto_generated_username_enabled():
username = get_auto_generated_username(details)
else:
username = uuid4().hex
if email_as_username and details.get('email'):
username = details['email']
elif details.get('username'):
username = details['username']
else:
username = uuid4().hex

input_username = username
final_username = slug_func(clean_func(username[:max_length]))
Expand Down

0 comments on commit 9ec7164

Please sign in to comment.