Skip to content

Commit 93f5892

Browse files
committed
fix: logout via POST
1 parent 4384f70 commit 93f5892

File tree

3 files changed

+18
-34
lines changed

3 files changed

+18
-34
lines changed

basxbread/layout/components/shell_header.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import htmlgenerator as hg
2+
from django.forms import Form
23
from django.utils.translation import gettext_lazy as _
34

45
from basxbread.utils import reverse
56

67
from ..utils import HasBasxBreadCookieValue
8+
from . import forms
79
from .icon import Icon
810

911

@@ -38,24 +40,21 @@ def __init__(self, platform, company, searchbar, actions=(), *args, **kwargs):
3840
),
3941
hg.If(
4042
hg.C("request.user.is_authenticated"),
41-
hg.BUTTON(
42-
Icon(
43-
"logout",
44-
size=20,
45-
_class="bx--navigation-menu-panel-expand-icon",
46-
aria_hidden="true",
43+
forms.Form(
44+
Form(),
45+
hg.BUTTON(
46+
Icon(
47+
"logout",
48+
size=20,
49+
_class="bx--navigation-menu-panel-expand-icon",
50+
aria_hidden="true",
51+
),
52+
_class="bx--header__menu-trigger bx--header__action",
53+
title=_("Logout"),
54+
# onclick=f"document.location = '{reverse('logout')}'",
4755
),
48-
Icon(
49-
"logout",
50-
size=20,
51-
_class="bx--navigation-menu-panel-collapse-icon",
52-
aria_hidden="true",
53-
),
54-
_class="bx--header__menu-trigger bx--header__action",
55-
title=_("Logout"),
56-
data_navigation_menu_panel_label_expand=_("Logout"),
57-
data_navigation_menu_panel_label_collapse=_("Close"),
58-
onclick=f"document.location = '{reverse('logout')}'",
56+
action=reverse("logout"),
57+
method="POST",
5958
),
6059
),
6160
_class="bx--header__global",

basxbread/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import django_celery_results.models
22
from django.apps import apps
33
from django.contrib.auth.models import Group, User
4+
from django.contrib.auth.views import LogoutView
45
from django.urls import include, path
56

67
from .utils import autopath, default_model_paths
@@ -15,7 +16,7 @@
1516
),
1617
path(
1718
"accounts/logout/",
18-
auth.LogoutView.as_view(),
19+
LogoutView.as_view(),
1920
name="logout",
2021
),
2122
path(

basxbread/views/auth.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import htmlgenerator as hg
22
from django.conf import settings
33
from django.contrib.auth.views import LoginView as DjangoLoginView
4-
from django.contrib.auth.views import LogoutView as DjangoLogoutView
54
from django.contrib.auth.views import (
65
PasswordResetCompleteView as DjangoPasswordResetCompleteView,
76
)
@@ -95,21 +94,6 @@ def get_form(self, *args, **kwargs):
9594
return form
9695

9796

98-
class LogoutView(BaseView, DjangoLogoutView):
99-
def get(self, *args, **kwargs):
100-
super().get(*args, **kwargs)
101-
return redirect("login")
102-
103-
def get_context_data(self, *args, **kwargs):
104-
return {
105-
**super().get_context_data(*args, **kwargs),
106-
"pagetitle": _("Logout"),
107-
}
108-
109-
def get_layout(self):
110-
return hg.DIV(_("Logged out"))
111-
112-
11397
class PasswordResetView(BaseView, DjangoPasswordResetView):
11498
def get_context_data(self, *args, **kwargs):
11599
return {

0 commit comments

Comments
 (0)