I am successfully able to login via Google and Facebook using Django (1.6.4) and allauth (0.16.1) and Python (2.7) with expected redirect to settings.LOGIN_REDIRECT_URL in case when there isn't a existing user with emailid retrieved from provider. However, when there already exists an user with same emailid as the one retrieved from provider (fb or goolge), it always redirects to /accounts/social/signup/#= signup page asking:
You are about to use your Facebook/Google account to login to example.com. As a final step, please complete the following form: Email is auto-filled.
I have tested with SOCIALACCOUNT_AUTO_SIGNUP = True
or False
, but no effect. I tried changing auth_type for facebook, but I don't see any options other than "rerequest"
I have the following settings.py:
ACCOUNT_AUTHENTICATION_METHOD = "email" # Defaults to username_email
ACCOUNT_USERNAME_REQUIRED = False # Defaults to True
ACCOUNT_EMAIL_REQUIRED = True # Defaults to False
SOCIALACCOUNT_QUERY_EMAIL = ACCOUNT_EMAIL_REQUIRED
SOCIALACCOUNT_AUTO_SIGNUP = True
SOCIALACCOUNT_EMAIL_REQUIRED = False
ACCOUNT_ADAPTER = "myproject.adapter.MyLoginAccountAdapter"
LOGIN_URL = "/"
LOGIN_REDIRECT_URL = "/users/{id}/mytags"
How can I stop this redirecting to signup, and have provider login redirect to LOGIN_REDIRECT_URL in the particular of an already existing user with same emailid?
NOTE: This I have tried
- I have already updated get_login_redirect_url in myproject.adapter.MyLoginAccountAdapter. Only works for google, but not for facebook as claimed by Django allauth - set facebook redirect
- I have tried "Bypass signup form using allauth" but doesn't work
UPDATES:
- Thanks to this answer, I realized that the login via facebook will redirect to signup page in a case: when the email retrieved from facebook profile matches already existing user's emailid.
- I have updated the question in order to account for the above case.
- To summarize the problem, this is a case where multiple provider accounts have same email id and django-allauth doesn't allow interchangeably login (e.i if i registered once using facebook, django-allauth will require me to use only facebook and not google or anything other provider with same email id)
- I have solved it by using
@receiver(pre_social_login)
andraise ImmediateHttpResponse
(look at my answer) with useful links: this and thisone
Thanks, Amit
SOCIALACCOUNT_EMAIL_AUTHENTICATION = True
? See Social Account Configuration