django allauth facebook redirects to signup when retrieved email matches an existing user's email? -
django allauth facebook redirects to signup when retrieved email matches an existing user's email? -
i able login via google , facebook using django (1.6.4) , allauth (0.16.1) , python (2.7) expected redirect settings.login_redirect_url in case when there isn't existing user emailid retrieved provider. however, when there exists user same emailid 1 retrieved provider (fb or goolge), redirects /accounts/social/signup/#= signup page asking:
you utilize facebook/google business relationship login example.com. final step, please finish next form: email auto-filled.
i have tested socialaccount_auto_signup = true
or false
, no effect. tried changing auth_type facebook, don't see options other "rerequest"
i have next settings.py:
account_authentication_method = "email" # defaults username_email account_username_required = false # defaults true account_email_required = true # defaults 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 stop redirecting signup, , have provider login redirect login_redirect_url in particular of existing user same emailid?
note: have tried
i have updated get_login_redirect_url in myproject.adapter.myloginaccountadapter. works google, not facebook claimed django allauth - set facebook redirect i have tried "bypass signup form using allauth" doesn't workupdates:
thanks answer, realized login via facebook redirect signup page in case: when email retrieved facebook profile matches existing user's emailid. i have updated question in order business relationship above case. to summarize problem, case multiple provider accounts have same email id , django-allauth doesn't allow interchangeably login (e.i if registered 1 time using facebook, django-allauth require me utilize facebook , not google or other provider same email id) i have solved using@receiver(pre_social_login)
, raise immediatehttpresponse
(look @ answer) useful links: this , thisone thanks, amit
i have solved after digging in deep google , source code of django , django-allauth
problem beingness solved: want ability interchangeably login using facebook , google same email id , redirect login_redirect_url after successful login, django-allauth doesn't allow me that. instead, presents me signup page don't want.
solution:: utilize @receiver(pre_social_login)
phone call function link_to_local_user()
logs in 1st , raises immediatehttpresponse in turn redirects login_redirect_url
#! myproject.adapter.py allauth.account.adapter import defaultaccountadapter allauth.socialaccount.adapter import defaultsocialaccountadapter allauth.exceptions import immediatehttpresponse allauth.socialaccount.signals import pre_social_login allauth.account.utils import perform_login allauth.utils import get_user_model django.http import httpresponse django.dispatch import receiver django.shortcuts import redirect django.conf import settings import json class myloginaccountadapter(defaultaccountadapter): ''' overrides allauth.account.adapter.defaultaccountadapter.ajax_response avoid changing http status_code 400 ''' def get_login_redirect_url(self, request): """ """ if request.user.is_authenticated(): homecoming settings.login_redirect_url.format( id=request.user.id) else: homecoming "/" class mysocialaccountadapter(defaultsocialaccountadapter): ''' overrides allauth.socialaccount.adapter.defaultsocialaccountadapter.pre_social_login perform actions right after successful login ''' def pre_social_login(self, request, sociallogin): pass # todofuture: perform actions right after successful login @receiver(pre_social_login) def link_to_local_user(sender, request, sociallogin, **kwargs): ''' login , redirect done in order tackle situation user's email retrieved 1 provider different existing email in database (e.g facebook , google both utilize same email-id). specifically, done tackle next issues: * https://github.com/pennersr/django-allauth/issues/215 ''' email_address = sociallogin.account.extra_data['email'] user = get_user_model() users = user.objects.filter(email=email_address) if users: # allauth.account.app_settings.emailverificationmethod perform_login(request, users[0], email_verification='optional') raise immediatehttpresponse(redirect(settings.login_redirect_url.format(id=request.user.id))) #! settings.py account_authentication_method = "email" # defaults username_email account_username_required = false # defaults true account_email_required = true # defaults false socialaccount_query_email = account_email_required socialaccount_auto_signup = true socialaccount_email_required = false account_adapter = "myproject.adapter.myloginaccountadapter" socialaccount_adapter = 'myproject.adapter.mysocialaccountadapter' login_url = "/" login_redirect_url = "/users/{id}/mytags"
django django-allauth
Comments
Post a Comment