Merge branch 'Qwann/anonymous' into 'master'
only clipper can autosign-up See merge request cof-geek/WikiENS!3
This commit is contained in:
commit
0b0ebd78f4
2 changed files with 23 additions and 0 deletions
|
@ -161,6 +161,9 @@ AUTHENTICATION_BACKENDS = [
|
|||
'allauth.account.auth_backends.AuthenticationBackend',
|
||||
]
|
||||
|
||||
ACCOUNT_ADAPTER = 'shared.allauth_adapter.AccountAdapter'
|
||||
SOCIALACCOUNT_ADAPTER = 'shared.allauth_adapter.SocialAccountAdapter'
|
||||
|
||||
HOME_URL = reverse_lazy('wiki:root')
|
||||
|
||||
LOGIN_URL = '_profil/login/'
|
||||
|
|
20
shared/allauth_adapter.py
Normal file
20
shared/allauth_adapter.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from allauth.account.adapter import DefaultAccountAdapter
|
||||
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
|
||||
|
||||
|
||||
class AccountAdapter(DefaultAccountAdapter):
|
||||
def is_open_for_signup(self, request):
|
||||
return False
|
||||
|
||||
|
||||
class SocialAccountAdapter(DefaultSocialAccountAdapter):
|
||||
def is_open_for_signup(self, request, sociallogin):
|
||||
# sociallogin.account is a SocialAccount instance.
|
||||
# See https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/models.py
|
||||
|
||||
if sociallogin.account.provider == 'clipper':
|
||||
return True
|
||||
|
||||
# It returns AccountAdapter.is_open_for_signup().
|
||||
# See https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/adapter.py
|
||||
return super().is_open_for_signup(request, sociallogin)
|
Loading…
Reference in a new issue