made it possible to disable signup
This commit is contained in:
15
cookbook/helper/AllAuthCustomAdapter.py
Normal file
15
cookbook/helper/AllAuthCustomAdapter.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
from allauth.account.adapter import DefaultAccountAdapter
|
||||||
|
|
||||||
|
|
||||||
|
class AllAuthCustomAdapter(DefaultAccountAdapter):
|
||||||
|
|
||||||
|
def is_open_for_signup(self, request):
|
||||||
|
"""
|
||||||
|
Whether to allow sign ups.
|
||||||
|
"""
|
||||||
|
allow_signups = super(
|
||||||
|
AllAuthCustomAdapter, self).is_open_for_signup(request)
|
||||||
|
# Override with setting, otherwise default to super.
|
||||||
|
return getattr(settings, 'ACCOUNT_ALLOW_SIGNUPS', allow_signups)
|
@ -1,4 +1,5 @@
|
|||||||
import cookbook.helper.dal
|
import cookbook.helper.dal
|
||||||
|
from cookbook.helper.AllAuthCustomAdapter import AllAuthCustomAdapter
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'dal',
|
'dal',
|
||||||
|
@ -27,9 +27,6 @@ DEMO = bool(int(os.getenv('DEMO', False)))
|
|||||||
|
|
||||||
INTERNAL_IPS = os.getenv('INTERNAL_IPS').split(',') if os.getenv('INTERNAL_IPS') else ['127.0.0.1']
|
INTERNAL_IPS = os.getenv('INTERNAL_IPS').split(',') if os.getenv('INTERNAL_IPS') else ['127.0.0.1']
|
||||||
|
|
||||||
# django allauth site id
|
|
||||||
SITE_ID = int(os.getenv('ALLAUTH_SITE_ID', 1))
|
|
||||||
|
|
||||||
# allow djangos wsgi server to server mediafiles
|
# allow djangos wsgi server to server mediafiles
|
||||||
GUNICORN_MEDIA = bool(int(os.getenv('GUNICORN_MEDIA', True)))
|
GUNICORN_MEDIA = bool(int(os.getenv('GUNICORN_MEDIA', True)))
|
||||||
|
|
||||||
@ -101,15 +98,42 @@ MIDDLEWARE = [
|
|||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Auth related settings
|
||||||
AUTHENTICATION_BACKENDS = [
|
AUTHENTICATION_BACKENDS = [
|
||||||
'django.contrib.auth.backends.ModelBackend',
|
'django.contrib.auth.backends.ModelBackend',
|
||||||
'allauth.account.auth_backends.AuthenticationBackend',
|
'allauth.account.auth_backends.AuthenticationBackend',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# django allauth site id
|
||||||
|
SITE_ID = int(os.getenv('ALLAUTH_SITE_ID', 1))
|
||||||
|
|
||||||
|
ACCOUNT_ADAPTER = 'cookbook.helper.AllAuthCustomAdapter'
|
||||||
|
|
||||||
|
# disable account creation using allauth
|
||||||
|
ACCOUNT_ALLOW_SIGNUPS = bool(int(os.getenv('ACCOUNT_ALLOW_SIGNUPS', False)))
|
||||||
|
|
||||||
if REVERSE_PROXY_AUTH:
|
if REVERSE_PROXY_AUTH:
|
||||||
MIDDLEWARE.append('recipes.middleware.CustomRemoteUser')
|
MIDDLEWARE.append('recipes.middleware.CustomRemoteUser')
|
||||||
AUTHENTICATION_BACKENDS.append('django.contrib.auth.backends.RemoteUserBackend')
|
AUTHENTICATION_BACKENDS.append('django.contrib.auth.backends.RemoteUserBackend')
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
@ -157,24 +181,6 @@ DATABASES = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
# Vue webpack settings
|
# Vue webpack settings
|
||||||
VUE_DIR = os.path.join(BASE_DIR, 'vue')
|
VUE_DIR = os.path.join(BASE_DIR, 'vue')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user