Skip to content

Commit

Permalink
fix: logout via POST
Browse files Browse the repository at this point in the history
  • Loading branch information
saemideluxe committed Jan 7, 2025
1 parent 4384f70 commit 93f5892
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 34 deletions.
33 changes: 16 additions & 17 deletions basxbread/layout/components/shell_header.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import htmlgenerator as hg
from django.forms import Form
from django.utils.translation import gettext_lazy as _

from basxbread.utils import reverse

from ..utils import HasBasxBreadCookieValue
from . import forms
from .icon import Icon


Expand Down Expand Up @@ -38,24 +40,21 @@ def __init__(self, platform, company, searchbar, actions=(), *args, **kwargs):
),
hg.If(
hg.C("request.user.is_authenticated"),
hg.BUTTON(
Icon(
"logout",
size=20,
_class="bx--navigation-menu-panel-expand-icon",
aria_hidden="true",
forms.Form(
Form(),
hg.BUTTON(
Icon(
"logout",
size=20,
_class="bx--navigation-menu-panel-expand-icon",
aria_hidden="true",
),
_class="bx--header__menu-trigger bx--header__action",
title=_("Logout"),
# onclick=f"document.location = '{reverse('logout')}'",
),
Icon(
"logout",
size=20,
_class="bx--navigation-menu-panel-collapse-icon",
aria_hidden="true",
),
_class="bx--header__menu-trigger bx--header__action",
title=_("Logout"),
data_navigation_menu_panel_label_expand=_("Logout"),
data_navigation_menu_panel_label_collapse=_("Close"),
onclick=f"document.location = '{reverse('logout')}'",
action=reverse("logout"),
method="POST",
),
),
_class="bx--header__global",
Expand Down
3 changes: 2 additions & 1 deletion basxbread/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import django_celery_results.models
from django.apps import apps
from django.contrib.auth.models import Group, User
from django.contrib.auth.views import LogoutView
from django.urls import include, path

from .utils import autopath, default_model_paths
Expand All @@ -15,7 +16,7 @@
),
path(
"accounts/logout/",
auth.LogoutView.as_view(),
LogoutView.as_view(),
name="logout",
),
path(
Expand Down
16 changes: 0 additions & 16 deletions basxbread/views/auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import htmlgenerator as hg
from django.conf import settings
from django.contrib.auth.views import LoginView as DjangoLoginView
from django.contrib.auth.views import LogoutView as DjangoLogoutView
from django.contrib.auth.views import (
PasswordResetCompleteView as DjangoPasswordResetCompleteView,
)
Expand Down Expand Up @@ -95,21 +94,6 @@ def get_form(self, *args, **kwargs):
return form


class LogoutView(BaseView, DjangoLogoutView):
def get(self, *args, **kwargs):
super().get(*args, **kwargs)
return redirect("login")

def get_context_data(self, *args, **kwargs):
return {
**super().get_context_data(*args, **kwargs),
"pagetitle": _("Logout"),
}

def get_layout(self):
return hg.DIV(_("Logged out"))


class PasswordResetView(BaseView, DjangoPasswordResetView):
def get_context_data(self, *args, **kwargs):
return {
Expand Down

0 comments on commit 93f5892

Please sign in to comment.