mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-01-24 00:04:13 +03:00
[IMP] django-allauth configuration: Allow enable or disable user registration using ACCOUNT_ALLOW_REGISTRATION setting.
This commit is contained in:
parent
062d6d31a4
commit
cc1da172f4
|
@ -69,6 +69,7 @@ Code Contributors
|
|||
* Jan Van Bruggen / @jvanbrug
|
||||
* Jon Miller / @jondelmil
|
||||
* Thomas Korrison / @failsafe86
|
||||
* David Díaz / @DavidDiazPinto *
|
||||
|
||||
\* Possesses commit rights
|
||||
|
||||
|
|
|
@ -45,3 +45,10 @@ DJANGO_OPBEAT_APP_ID OPBEAT['APP_ID'] n/a
|
|||
DJANGO_OPBEAT_SECRET_TOKEN OPBEAT['SECRET_TOKEN'] n/a raises error
|
||||
DJANGO_OPBEAT_ORGANIZATION_ID OPBEAT['ORGANIZATION_ID'] n/a raises error
|
||||
======================================= =========================== ============================================== ======================================================================
|
||||
|
||||
--------------
|
||||
Other Settings
|
||||
--------------
|
||||
|
||||
ACCOUNT_ALLOW_REGISTRATION (=True)
|
||||
Allow enable or disable user registration through `django-allauth` without disabling other characteristics like authentication and account management.
|
|
@ -211,6 +211,9 @@ AUTHENTICATION_BACKENDS = (
|
|||
ACCOUNT_AUTHENTICATION_METHOD = 'username'
|
||||
ACCOUNT_EMAIL_REQUIRED = True
|
||||
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
||||
ACCOUNT_ADAPTER = '{{cookiecutter.repo_name}}.users.adapter.AccountAdapter'
|
||||
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.repo_name}}.users.adapter.SocialAccountAdapter'
|
||||
ACCOUNT_ALLOW_REGISTRATION = True
|
||||
|
||||
# Custom user app defaults
|
||||
# Select the correct user model
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.conf import settings
|
||||
from allauth.account.adapter import DefaultAccountAdapter
|
||||
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
|
||||
|
||||
|
||||
class AccountAdapter(DefaultAccountAdapter):
|
||||
def is_open_for_signup(self, request):
|
||||
return getattr(settings, 'ACCOUNT_ALLOW_REGISTRATION', True)
|
||||
|
||||
|
||||
class SocialAccountAdapter(DefaultSocialAccountAdapter):
|
||||
def is_open_for_signup(self, request):
|
||||
return getattr(settings, 'ACCOUNT_ALLOW_REGISTRATION', True)
|
Loading…
Reference in New Issue
Block a user