Open Meess opened 3 months ago
Hi, it seems this is a similar issue: https://github.com/iMerica/dj-rest-auth/issues/658
Hi, it seems this is a similar issue: #658
@benshaji-sequoiaat yes look like a similar issue. As I mentioned in this issue there is a hacky workaround.
I have little trust this will be solved as the README.md especially mentions:
This project has optional and very narrow support for Django-AllAuth. As the maintainer, I have no interest in making this package support all use cases in Django-AllAuth. I would rather focus on improving the quality of the base functionality or focus on OIDC support instead. Pull requests that extend or add more support for Django-AllAuth will most likely be declined. Do you disagree? Feel free to fork this repo!
I'm looking into all-auth headless to replace this library: https://docs.allauth.org/en/latest/headless/index.html
Config
Using all-auth social login with Google
Using the following settings:
Functional Issue
Not signed up user has to login twice before actually logged in.
The first time a user logs in always results in a ValidationError with message
'User is already registered with this e-mail address.'
. However the user is actually created in de db, even though the error occurs. If the user logs in again, it recognises the user in the database and logs you in with status 200 (i.e. user is actually logged in).Issue
SocialLoginSerializer.validate(..)
itself checks if the e-mail adress is already in use on signup, however prior to that is call the all-auth functioncomplete_social_login
which already checks this, and saves the user:SocialLoginSerializer.validate(...) calls allauth's complete_social_login
Possible solution
The returned login variable
login.is_existing
is checked to see if a user already existed, if not it goes and checks the email adress. Howeverlogin.user
can also be checked, as allauth fillslogin.user
with the created user object on signup, dj-rest-auth could check this and see if it already has an ID. If it has an ID it knows the user is already created (and then assume allauth did proper validation) and hence skip the email check.Workaround (hacky)
Create a custom SocialLoginSerializer, copy only yhe validate function from the original code and comment out the email check.