Logout: fix redirect

Without this, we were getting into a loop with keep alive enabled
when using Firefox.

Signed-off-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
XhmikosR
2025-03-09 08:52:59 +02:00
parent e3ead702ce
commit 6c29d5dab8
3 changed files with 6 additions and 4 deletions

View File

@@ -9,8 +9,10 @@
document.addEventListener("DOMContentLoaded", () => {
const logoutButton = document.getElementById("logout-button");
const logoutUrl = document.body.dataset.logoutUrl;
logoutButton.addEventListener("click", event => {
event.preventDefault();
utils.doLogout();
utils.doLogout(logoutUrl);
});
});

View File

@@ -463,12 +463,12 @@ function changeBulkDeleteStates(table) {
}
}
function doLogout() {
function doLogout(url) {
$.ajax({
url: apiUrl + "/auth",
method: "DELETE",
}).always(function () {
location.reload();
globalThis.location = url;
});
}

View File

@@ -22,7 +22,7 @@ mg.include('header.lp','r')
<script defer src="<?=pihole.fileversion('vendor/bstreeview/bstreeview.min.js')?>"></script>
<script defer src="<?=pihole.fileversion('scripts/js/logout.js')?>"></script>
</head>
<body class="<?=theme.name?> hold-transition sidebar-mini <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in" data-apiurl="<?=pihole.api_url()?>">
<body class="<?=theme.name?> hold-transition sidebar-mini <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in" data-apiurl="<?=pihole.api_url()?>" data-logout-url="<?=webhome .. 'login'?>">
<noscript>
<!-- JS Warning -->
<div>