From b119eae9b4937e56fcbc83349b7456df143927de Mon Sep 17 00:00:00 2001 From: Jens Kaeske <39417308+jkaeske@users.noreply.github.com> Date: Sat, 18 May 2024 22:53:52 +0200 Subject: [PATCH] Fix redirect error when forcing allauth login in admin site (#5078) --- .../{{cookiecutter.project_slug}}/users/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py index 70f8292565..40086de7f7 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/admin.py @@ -1,7 +1,7 @@ +from allauth.account.decorators import secure_admin_login from django.conf import settings from django.contrib import admin from django.contrib.auth import admin as auth_admin -from django.contrib.auth.decorators import login_required from django.utils.translation import gettext_lazy as _ from .forms import UserAdminChangeForm @@ -11,7 +11,8 @@ if settings.DJANGO_ADMIN_FORCE_ALLAUTH: # Force the `admin` sign in process to go through the `django-allauth` workflow: # https://docs.allauth.org/en/latest/common/admin.html#admin - admin.site.login = login_required(admin.site.login) # type: ignore[method-assign] + admin.autodiscover() + admin.site.login = secure_admin_login(admin.site.login) # type: ignore[method-assign] @admin.register(User)