Prevent social account creation in allauth

痞子三分冷 提交于 2019-12-05 13:26:36

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!