Search code examples
djangopython-social-auth

social auth app django integrity error when user is logged out


Im trying to integrate facebook login to my app. When i associate a facebook account to the user and then logout,The login with facebook is working as intended.But if the user has his facebook disconnected and when i click login with facebook,Im getting an integrity error at :

IntegrityError at /oauth/complete/facebook/
duplicate key value violates unique constraint "accounts_user_email_key"
DETAIL:  Key (email)=() already exists.

Im using social-auth-app-django

In my settings.py,i have:

DEFAULT_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.auth_allowed',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.mail.mail_validation',
'social_core.pipeline.social_auth.associate_by_email',
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details'
)

Solution

  • Reordering the pipelines did the trick!:

    SOCIAL_AUTH_PIPELINE = (
    'social_core.pipeline.user.get_username',
    'social_core.pipeline.mail.mail_validation',
    'social_core.pipeline.social_auth.social_uid',
    
    'social_core.pipeline.social_auth.associate_user',
    'social_core.pipeline.social_auth.load_extra_data',
    'social_core.pipeline.user.user_details',
    'social_core.pipeline.social_auth.social_details',
    'social_core.pipeline.social_auth.auth_allowed',
    'social_core.pipeline.social_auth.social_user',
    

    )