Social auth django : Multiple Users conflict with same email id

966 views Asked by At

I am using django social auth for social login. If a user signs up using gmail id, on his next visit logins using gmail social login, then two users are created for the same user with different username but same email id. Now when user tries login using this gmail id, MultipleObjectsReturned error is thrown.

Is there any way to check the email id of a user when logging, if it already exists associate it with the that user.

2

There are 2 answers

0
Raja Simon On BEST ANSWER

You may have to show what PIPELINE you provide in your settings.py file.

But thing answer is :

Include in settings like 'social_auth.backends.pipeline.associate.associate_by_email',

1
Nidhi On

In settings.py add:

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'social.pipeline.social_auth.associate_by_email',
    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
)