[Fixed]-Django: How to identifying through which link user done social authentication?

1👍

Seems to be I myself figured out to implement this by SOCIAL_AUTH_PIPELINE concept based on the following documentation reference.

following is the modifications I have done:
Added SOCIAL_AUTH_PIPELINE into setting.py with custom a pipeline

# social authentication 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',
# custom pipeline
    'user_profile.pipeline.create_user_profile'
)

Also added FIELDS_STORED_IN_SESSION in settings.py, as follows

FIELDS_STORED_IN_SESSION = ['profile_type']

Then in user_profile.pipeline.py, defined function create_user_profile as follows:

def create_user_profile(strategy, details, user=None, is_new=False, *args, **kwargs):
    print(strategy.session_get('profile_type'))

Now from strategy object I can access the custom value to create different type of user profile.
Link of reference

On the main link in which user clicks, added an extra argument at the end of url as follows:

http://domain.name.com/signupurl?profile_type=type1
http://domain.name.com/signupurl?profile_type=type2
👤Dipak

Leave a comment