问题
Is it possible to prevent account creation under certain circumstances in allauth, preferably using the pre_social_login signal?
回答1:
With the current development branch you can easily do this. In your settings:
SOCIALACCOUNT_ADAPTER = 'my.adapter.MySocialAccountAdapter'
Then use this 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'))
Alternatively, raise a similar exception from your pre_social_login
signal (although I do not prefer that approach -- see documentation notes over at https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/adapter.py#L15
来源:https://stackoverflow.com/questions/13646805/prevent-social-account-creation-in-allauth