Disable user registration with django-social-auth

997 Views Asked by At

I would like to know if anyone knows if there is a way to make django-social-auth throw an error if the social account is not associated to a site account and not to register a new user?

1

There are 1 best solutions below

0
On

You can make that possible by overriding the pipeline setting with one that drops create_user entry (there's an example in the pipeline docs at http://python-social-auth-docs.readthedocs.io/en/latest/pipeline.html). Basically define this setting:

SOCIAL_AUTH_PIPELINE = (
    'social_auth.backends.pipeline.social.social_auth_user',
    'social_auth.backends.pipeline.social.associate_user',
    'social_auth.backends.pipeline.social.load_extra_data',
    'social_auth.backends.pipeline.user.update_user_details'
)

Also you could add your own entry that does the check for you, like this:

def user_must_exists(user=None, *args, **kwargs):
    if user is None:
        raise YourExceptionHere()