use*_*104 4 django django-authentication django-allauth
是否有可能在某些情况下防止在allauth中创建帐户,最好使用pre_social_login信号?
使用当前的开发分支,您可以轻松完成此操作.在您的设置中:
SOCIALACCOUNT_ADAPTER = 'my.adapter.MySocialAccountAdapter'
Run Code Online (Sandbox Code Playgroud)
然后使用此adapter.py:
from django.http import HttpResponse
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
from allauth.exceptions import ImmediateHttpResponse
class MySocialAccountAdapter(DefaultSocialAccountAdapter):
def pre_social_login(self, request, sociallogin):
raise ImmediateHttpResponse(HttpResponse('Closed for the day'))
Run Code Online (Sandbox Code Playgroud)
或者,从您的pre_social_login信号中引发类似的异常(虽然我不喜欢这种方法 - 请参阅https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/adapter.py#上的文档说明.L15
| 归档时间: |
|
| 查看次数: |
1281 次 |
| 最近记录: |