I am using django social-auth (http://django-social-auth.readthedocs.org/en/latest/index.html) and trying to create a user profile where the user can associate multiple accounts (like here on Stackoverflow).
Currently I am at the point where single user can login using different authentication providers, but for each login a new user is created. How can I associate all user accounts into single one (like user profile)?
Also, what is the best practice for creating user profile page when using django social-auth?
DSA already supports multiple account association, the trick is to it is that the user must be logged in, otherwise DSA doesn't know it should be associated with an already existing account.
Regarding your profile, the recommended way to add functionality to DSA is by extending the pipeline, you can create an entry like this:
def create_profile(user, is_new=False, *args, **kwargs):
if is_new:
# create a profile instance for the given user
create_user_profile(user)
Then register it in the settings like this:
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
'myapp.pipeline.create_profile'
)
Where the entry is the import path to get that function.
Edit: linking to docs and setting explanation.