django-allauth社交帐户在登录时连接到现有帐户

django-allauth社交帐户在登录时连接到现有帐户,第1张

django-allauth社交帐户在登录时连接到现有帐户

我设法通过稍微更改适配器的代码来使其工作。

adapter.py

from allauth.socialaccount.adapter import DefaultSocialAccountAdapterclass MySocialAccountAdapter(DefaultSocialAccountAdapter):    def pre_social_login(self, request, sociallogin):         user = sociallogin.user        if user.id:   return       try: customer = Customer.objects.get(email=user.email)  # if user exists, connect the account to the existing account and login sociallogin.state['process'] = 'connect'      perform_login(request, customer, 'none')        except Customer.DoesNotExist: pass

如果是子类

DefaultSocialAccountAdapter
,我们必须
SOCIALACCOUNT_ADAPTER ='myapp.my_adapter.MySocialAccountAdapter'
settings.py
文件中指定



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5617427.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存