Ejemplo n.º 1
0
    def test_is_oauth_provider(self, provider_id, oauth_provider):
        """
        Tests if the backend name is that of an auth provider or not
        """
        with mock.patch(
            'common.djangoapps.third_party_auth.utils.provider.Registry.get_from_pipeline'
        ) as get_from_pipeline:
            get_from_pipeline.return_value.provider_id = provider_id

            self.assertEqual(is_oauth_provider('backend_name'), oauth_provider)
Ejemplo n.º 2
0
def associate_by_email_if_oauth(auth_entry, backend, details, user, strategy, *args, **kwargs):
    """
    This pipeline step associates the current social auth with the user with the
    same email address in the database.  It defers to the social library's associate_by_email
    implementation, which verifies that only a single database user is associated with the email.

    This association is done ONLY if the user entered the pipeline belongs to Oauth provider and
    `ENABLE_REQUIRE_THIRD_PARTY_AUTH` is enabled.
    """

    if is_require_third_party_auth_enabled() and is_oauth_provider(backend.name, **kwargs):
        association_response, user_is_active = get_associated_user_by_email_response(
            backend, details, user, *args, **kwargs)

        if user_is_active:
            return association_response