I suspect the reason of the error but I don't know how to solve it, this is what happened:
I did a pg_dump
on a local database and then a pg_restore
on the production database on Heroku. Now, when someone with a already existing username tries to login (using facebook or google etc), PSA creates a new user with a random number appended at the end instead of login the existing user in.
For example, the user with the username JohnSmith logs in with FB, because JohnSmith already exists in the db, it creates a new user with the username JohnSmit654f6b654
I guess the pg_restore
I used to restore the database backup somehow didn't include some important psa tables. I'd like to know which Python Social Auth tables I should restore manually so that it works correctly. Or... maybe there is a different reason for the error. Thanks for your help.
Btw, Im using Django 1.8 on Heroku.
Edit
My Social Auth Pipeline:
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.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
'letrasclub.utils.create_profile'
)
Its the normal pipeline + create_profile
, that last pipeline only creates a profile for the user if it doesn't have one. It probably isn't the source of the problem cause the problem is the pipeline is creating new users, that happens in 'social.pipeline.user.create_user'
.
Ok, Nikolay F answer helped me but it is not the answer to this question.
This is what solved it for me, just in case someone finds it useful:
Do a manage.py dumpdata
on the old database (which has the correct data on the social auth tables, including social_auth_usersocialauth
)
python manage.py dumpdata default > social.json
The trick here is to know that Python Social Auth's doesn't have an app label but the command works with default
.
Then, pushed the file to heroku and ran:
heroku run python manage.py loaddata social.json
That solved it.