Fix redirect error when forcing allauth login in admin site (#5078)

This commit is contained in:
Jens Kaeske 2024-05-18 22:53:52 +02:00 committed by GitHub
parent b9f6d8875e
commit b119eae9b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 @@ from .models import User
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)