fix: should autogenerate username in tpa pipeline if feature is enabled (#35101)

This commit is contained in:
Syed Sajjad Hussain Shah
2024-07-09 13:39:36 +05:00
committed by GitHub
parent 3e090014f6
commit 67a1401f8a

View File

@@ -90,7 +90,9 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_
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,
@@ -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]))