diff --git a/digitalglarus/urls.py b/digitalglarus/urls.py index 21de04f2..89cff24b 100644 --- a/digitalglarus/urls.py +++ b/digitalglarus/urls.py @@ -1,4 +1,5 @@ from django.urls import re_path +from utils.views import LogoutView from django.utils.translation import gettext_lazy as _ from django.contrib.auth import views as auth_views @@ -24,7 +25,7 @@ urlpatterns = [ re_path(_(r'contact/?$'), ContactView.as_view(), name='contact'), re_path(_(r'login/?$'), LoginView.as_view(), name='login'), re_path(_(r'signup/?$'), SignupView.as_view(), name='signup'), - re_path(r'^logout/?$', auth_views.LogoutView.as_view( + re_path(r'^logout/?$', LogoutView.as_view( next_page='/digitalglarus/login?logged_out=true'), name='logout'), re_path(r'reset-password/?$', PasswordResetView.as_view(), name='reset_password'), re_path(r'reset-password-confirm/(?P[0-9A-Za-z]+)-(?P.+)/$', diff --git a/hosting/urls.py b/hosting/urls.py index 7b4d3a19..b6046e2e 100644 --- a/hosting/urls.py +++ b/hosting/urls.py @@ -1,4 +1,5 @@ from django.urls import re_path +from utils.views import LogoutView from django.contrib.auth import views as auth_views from utils.views import SSHKeyCreateView, AskSSHKeyView @@ -71,7 +72,7 @@ urlpatterns = [ name='reset_password'), re_path(r'reset-password-confirm/(?P[0-9A-Za-z]+)-(?P.+)/$', PasswordResetConfirmView.as_view(), name='reset_password_confirm'), - re_path(r'^logout/?$', auth_views.LogoutView.as_view( + re_path(r'^logout/?$', LogoutView.as_view( next_page='/hosting/login?logged_out=true'), name='logout'), re_path(r'^validate/(?P.*)/$', SignupValidatedView.as_view(), name='validate') diff --git a/nosystemd/urls.py b/nosystemd/urls.py index 8fbb947b..23a7ee19 100644 --- a/nosystemd/urls.py +++ b/nosystemd/urls.py @@ -1,4 +1,5 @@ from django.urls import re_path +from utils.views import LogoutView from django.contrib.auth import views as auth_views from .views import LandingView, LoginView, SignupView, PasswordResetView,\ @@ -11,7 +12,7 @@ urlpatterns = [ re_path(r'^$', LandingView.as_view(), name='landing'), re_path(r'^login/?$', LoginView.as_view(), name='login'), re_path(r'^signup/?$', SignupView.as_view(), name='signup'), - re_path(r'^logout/?$', auth_views.LogoutView.as_view( + re_path(r'^logout/?$', LogoutView.as_view( next_page='/nosystemd/login?logged_out=true'), name='logout'), re_path(r'reset-password/?$', PasswordResetView.as_view(), name='reset_password'), re_path(r'reset-password-confirm/(?P[0-9A-Za-z]+)-(?P.+)/$', diff --git a/utils/views.py b/utils/views.py index d6d3fc77..ab3cd2ab 100644 --- a/utils/views.py +++ b/utils/views.py @@ -11,6 +11,7 @@ from django.shortcuts import render from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.utils.translation import gettext_lazy as _ +from django.contrib.auth import views as auth_views from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_control from django.views.generic import FormView, CreateView @@ -267,4 +268,11 @@ class AskSSHKeyView(SSHKeyCreateView): def post(self, request, *args, **kwargs): self.success_url = self.request.session.get("order_confirm_url") - return super(AskSSHKeyView, self).post(self, request, *args, **kwargs) \ No newline at end of file + return super(AskSSHKeyView, self).post(self, request, *args, **kwargs) + +class LogoutView(auth_views.LogoutView): + """Django 5 dropped logging out with GET, but the logout links of the pages are plain links""" + http_method_names = ['get', 'post', 'options'] + + def get(self, request, *args, **kwargs): + return self.post(request, *args, **kwargs)