@@ -102,10 +102,7 @@ def B(*args, **kwargs):
102102 is_saml_provider ,
103103 user_exists ,
104104)
105- from common .djangoapps .third_party_auth .toggles import (
106- is_saml_provider_site_fallback_enabled ,
107- is_tpa_next_url_on_dispatch_enabled ,
108- )
105+ from common .djangoapps .third_party_auth .toggles import is_tpa_next_url_on_dispatch_enabled
109106from common .djangoapps .track import segment
110107from common .djangoapps .util .json_request import JsonResponse
111108
@@ -363,10 +360,10 @@ def get_complete_url(backend_name):
363360 ValueError: if no provider is enabled with the given backend_name.
364361 """
365362 if not any (provider .Registry .get_enabled_by_backend_name (backend_name )):
366- # When the SAML site-fallback flag is on , the provider may not be visible to the
367- # site-filtered registry even though SAML auth already completed via a
368- # site-independent lookup. Allow get_complete_url to proceed in that case.
369- if not ( is_saml_provider_site_fallback_enabled () and backend_name == 'tpa-saml' ) :
363+ # For tpa-saml , the provider may not be visible to the site-filtered registry
364+ # even though SAML auth already completed via a site-independent lookup.
365+ # Allow get_complete_url to proceed in that case.
366+ if backend_name != 'tpa-saml' :
370367 raise ValueError ('Provider with backend %s not enabled' % backend_name )
371368
372369 return _get_url ('social:complete' , backend_name )
@@ -621,33 +618,14 @@ def is_provider_saml():
621618 strategy .storage .partial .store (current_partial )
622619
623620 if not user :
624- # Use only email for user existence check in case of saml provider
625- _is_saml = is_provider_saml ()
626- _provider_obj = provider .Registry .get_from_pipeline ({'backend' : current_partial .backend , 'kwargs' : kwargs })
627- logger .info (
628- '[THIRD_PARTY_AUTH] ensure_user_information: auth_entry=%s backend=%s is_provider_saml=%s '
629- 'current_provider=%s skip_email_verification=%s send_to_registration_first=%s '
630- 'email=%s kwargs_response_keys=%s' ,
631- auth_entry ,
632- current_partial .backend ,
633- _is_saml ,
634- _provider_obj .provider_id if _provider_obj else None ,
635- _provider_obj .skip_email_verification if _provider_obj else None ,
636- _provider_obj .send_to_registration_first if _provider_obj else None ,
637- details .get ('email' ) if details else None ,
638- list ((kwargs .get ('response' ) or {}).keys ()),
639- )
640- if _is_saml :
621+ # Use only email for user existence check in case of saml provider.
622+ # Check the backend name directly rather than the site-filtered registry,
623+ # since the provider may only be visible via the site-independent fallback.
624+ if current_partial .backend == 'tpa-saml' :
641625 user_details = {'email' : details .get ('email' )} if details else None
642626 else :
643627 user_details = details
644- _user_exists = user_exists (user_details or {})
645- logger .info (
646- '[THIRD_PARTY_AUTH] ensure_user_information: user_exists=%s user_details_email=%s' ,
647- _user_exists ,
648- (user_details or {}).get ('email' ),
649- )
650- if _user_exists :
628+ if user_exists (user_details or {}):
651629 # User has not already authenticated and the details sent over from
652630 # identity provider belong to an existing user.
653631 logger .info ('[THIRD_PARTY_AUTH] ensure_user_information: dispatching to login (user exists)' )
@@ -658,12 +636,7 @@ def is_provider_saml():
658636 elif auth_entry == AUTH_ENTRY_LOGIN :
659637 # User has authenticated with the third party provider but we don't know which edX
660638 # account corresponds to them yet, if any.
661- _force = should_force_account_creation ()
662- logger .info (
663- '[THIRD_PARTY_AUTH] ensure_user_information: AUTH_ENTRY_LOGIN should_force_account_creation=%s' ,
664- _force ,
665- )
666- if _force :
639+ if should_force_account_creation ():
667640 return dispatch_to_register ()
668641 logger .info ('[THIRD_PARTY_AUTH] ensure_user_information: dispatching to login (no force create)' )
669642 return dispatch_to_login ()
0 commit comments