[IMP] django-allauth configuration: Allow enable or disable user registration using ACCOUNT_ALLOW_REGISTRATION setting.

This commit is contained in:
David Díaz 2015-12-05 20:12:53 +01:00
parent 062d6d31a4
commit cc1da172f4
4 changed files with 25 additions and 0 deletions

View File

@ -69,6 +69,7 @@ Code Contributors
* Jan Van Bruggen / @jvanbrug
* Jon Miller / @jondelmil
* Thomas Korrison / @failsafe86
* David Díaz / @DavidDiazPinto *
\* Possesses commit rights

View File

@ -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.

View File

@ -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

View File

@ -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)