0

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?

Mark Lavin
  • 24,664
  • 5
  • 76
  • 70

1 Answers1

1

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()
ayhan
  • 70,170
  • 20
  • 182
  • 203
omab
  • 3,721
  • 19
  • 23