diff --git a/common/djangoapps/third_party_auth/pipeline.py b/common/djangoapps/third_party_auth/pipeline.py index 1c602d6f222e..734876688236 100644 --- a/common/djangoapps/third_party_auth/pipeline.py +++ b/common/djangoapps/third_party_auth/pipeline.py @@ -586,20 +586,15 @@ def should_force_account_creation(): return (current_provider and (current_provider.skip_email_verification or current_provider.send_to_registration_first)) - def is_provider_saml(): - """ Verify that the third party provider uses SAML """ - current_provider = provider.Registry.get_from_pipeline({'backend': current_partial.backend, 'kwargs': kwargs}) - saml_providers_list = list(provider.Registry.get_enabled_by_backend_name('tpa-saml')) - return (current_provider and - current_provider.slug in [saml_provider.slug for saml_provider in saml_providers_list]) - if current_partial: strategy.session_set('partial_pipeline_token_', current_partial.token) strategy.storage.partial.store(current_partial) if not user: # Use only email for user existence check in case of saml provider - if is_provider_saml(): + saml_provider, _ = is_saml_provider(backend, kwargs) + + if saml_provider: user_details = {'email': details.get('email')} if details else None else: user_details = details diff --git a/common/djangoapps/third_party_auth/utils.py b/common/djangoapps/third_party_auth/utils.py index da0d55af12a4..0edcccde1275 100644 --- a/common/djangoapps/third_party_auth/utils.py +++ b/common/djangoapps/third_party_auth/utils.py @@ -80,8 +80,10 @@ def validate_uuid4_string(uuid_string): def is_saml_provider(backend, kwargs): """ Verify that the third party provider uses SAML """ - current_provider = provider.Registry.get_from_pipeline({'backend': backend, 'kwargs': kwargs}) - saml_providers_list = list(provider.Registry.get_enabled_by_backend_name('tpa-saml')) + current_provider = None + if backend: + current_provider = provider.Registry.get_from_pipeline({'backend': backend.name, 'kwargs': kwargs}) + saml_providers_list = list(provider.Registry.get_enabled_by_backend_name('tpa-saml')) return (current_provider and current_provider.slug in [saml_provider.slug for saml_provider in saml_providers_list]), current_provider