2
votes

I have started to use python-social-auth in a django project to authenticate the users from facebook, email, and potentially other sources. I was able to integrate it to my project, and to create new users with both facebook and email. I understand the concept of pipeline but something remains unclear to me:

How to differentiate login and signup? It seems to me that python-social-auth has a single pipeline for both login and signup actions.

I have implemented a signup and login (with email) template but for now, both submit the form to the url '/complete/email/'.

My loggin form only sends an email and a password but this creates a new user if the email does not allready exist.

How would you differentiate both use cases? Should I use the python-social-auth pipeline only for signup and implement a login view for my "log in with email" page as I would do if I were not using python-social-auth?

Thanks for any answer, experiences on how you did it or further explanation about python-social-auth concepts.

1
In the pipeline the is_new flag is passed which will be True/False to signal a new user or one that already exists in your application. Also you can define SOCIAL_AUTH_NEW_USER_REDIRECT_URL to redirect users that location after signup, also SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL does the same for users associating a new social account (but were already part of your system). - omab
Ok, if I understand correctly I should use the same pipeline in both cases, submitting both forms to the url '/complete/email' and treat them differently according to the is_new flag. Thanks for the hint, i'll dig into it! - overlii
Ok, To be more precise, I submit the login form to '/complete/email' with fields email and password and the signupform to '/complete/email' with fields email, password and username, since the username i required. My problem is that the login form is creating new users. - overlii
It seems that I have to create my own backend for the email login, I will return when I have more ;) - overlii

1 Answers

1
votes

So my solution was to switch back to standard django-style login-signup for the email backend. I found that it was easier for me to implement the workflow with two different forms and handling cases where user already exist and so on.

If you did it with python-social-auth, I would still be interested to hear about your solution but for now i'll use it for other authentication sources, where it pretty much works out of the box as I want it!!