mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-10 06:54:52 +03:00
Allow django-admin to optionally use django-allauth login workflow
This commit is contained in:
parent
156afe675b
commit
d9457c595b
|
@ -2,6 +2,10 @@
|
||||||
All enhancements and patches to Cookiecutter Django will be documented in this file.
|
All enhancements and patches to Cookiecutter Django will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [2019-01-30]
|
||||||
|
### Added
|
||||||
|
- Added `DJANGO_ADMIN_FORCE_ALLAUTH` environment variable to force the `admin` sign in process to go through the `django-allauth` workflow
|
||||||
|
|
||||||
## [2018-02-16]
|
## [2018-02-16]
|
||||||
### Changed
|
### Changed
|
||||||
- Upgraded to Django 2.0 (@epicwhale)
|
- Upgraded to Django 2.0 (@epicwhale)
|
||||||
|
|
|
@ -57,3 +57,6 @@ Other Environment Settings
|
||||||
|
|
||||||
DJANGO_ACCOUNT_ALLOW_REGISTRATION (=True)
|
DJANGO_ACCOUNT_ALLOW_REGISTRATION (=True)
|
||||||
Allow enable or disable user registration through `django-allauth` without disabling other characteristics like authentication and account management. (Django Setting: ACCOUNT_ALLOW_REGISTRATION)
|
Allow enable or disable user registration through `django-allauth` without disabling other characteristics like authentication and account management. (Django Setting: ACCOUNT_ALLOW_REGISTRATION)
|
||||||
|
|
||||||
|
DJANGO_ADMIN_FORCE_ALLAUTH (=False)
|
||||||
|
Force the `admin` sign in process to go through the `django-allauth` workflow.
|
||||||
|
|
|
@ -235,6 +235,9 @@ ADMINS = [
|
||||||
]
|
]
|
||||||
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
||||||
MANAGERS = ADMINS
|
MANAGERS = ADMINS
|
||||||
|
# https://cookiecutter-django.readthedocs.io/en/latest/settings.html#other-environment-settings
|
||||||
|
# Force the `admin` sign in process to go through the `django-allauth` workflow
|
||||||
|
DJANGO_ADMIN_FORCE_ALLAUTH = env.bool('DJANGO_ADMIN_FORCE_ALLAUTH', default=False)
|
||||||
|
|
||||||
{% if cookiecutter.use_celery == 'y' -%}
|
{% if cookiecutter.use_celery == 'y' -%}
|
||||||
# Celery
|
# Celery
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth import admin as auth_admin
|
from django.contrib.auth import admin as auth_admin
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model, decorators
|
||||||
|
|
||||||
from {{ cookiecutter.project_slug }}.users.forms import UserChangeForm, UserCreationForm
|
from {{ cookiecutter.project_slug }}.users.forms import UserChangeForm, UserCreationForm
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
if settings.DJANGO_ADMIN_FORCE_ALLAUTH:
|
||||||
|
# Force the `admin` sign in process to go through the `django-allauth` workflow
|
||||||
|
admin.site.login = decorators.login_required(admin.site.login)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(User)
|
@admin.register(User)
|
||||||
class UserAdmin(auth_admin.UserAdmin):
|
class UserAdmin(auth_admin.UserAdmin):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user