Skip to content

Commit 7352d97

Browse files
Merge pull request #1436 from opengisch/redirect-logout-view
feat: override Django admin logout view to redirect to Allauth's logout
2 parents 11e1108 + 6320eba commit 7352d97

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

docker-app/qfieldcloud/core/admin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from django.contrib.admin.templatetags.admin_urls import admin_urlname
2626
from django.contrib.admin.views.main import ChangeList
2727
from django.contrib.auth.models import Group
28-
from django.contrib.auth.views import redirect_to_login
28+
from django.contrib.auth.views import logout_then_login, redirect_to_login
2929
from django.core.exceptions import PermissionDenied, ValidationError
3030
from django.core.files.storage import storages
3131
from django.db.models import Q, QuerySet
@@ -101,6 +101,12 @@ def login(
101101
request.GET.get("next", ""), login_url=reverse(settings.LOGIN_URL)
102102
)
103103

104+
def logout( # type: ignore[override]
105+
self, request: HttpRequest, extra_context: dict[str, Any] | None = None
106+
) -> HttpResponse:
107+
"""Override the default Django admin logout view to redirect to the Allauth's logout view."""
108+
return logout_then_login(request)
109+
104110
# TODO consider adding a logout view to redirect to the Allauth's logout view, but then we lose the nice template we have right now.
105111

106112

docker-app/qfieldcloud/core/staticfiles/css/admin.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.login-logo img {
2-
width: 100%;
3-
}
4-
51
.object-tools{
62
margin-bottom: 1rem;
73
}

0 commit comments

Comments
 (0)