djangodjango-socialauth

Django Social Auth check if user is new in view


I'm using django-social-auth by @Omab for my site.

In the settings, I have SOCIAL_AUTH_NEW_USER_REDIRECT_URL set to, say, /profile. My question is, in the view, how do I check if the user is new? Is there a variable that I can access?


Solution

  • Found the solution.

    The variable is_new is set in the request.session variable. You can access it as follows:

    name = setting('SOCIAL_AUTH_PARTIAL_PIPELINE_KEY', 'partial_pipeline')
    if name in request.session:
        if request.session[name]['kwargs']['is_new'] == True:
            #Do something.
    

    Thanks for your answers!