Skip to content

Commit 6c29d5d

Browse files
committed
Logout: fix redirect
Without this, we were getting into a loop with keep alive enabled when using Firefox. Signed-off-by: XhmikosR <[email protected]>
1 parent e3ead70 commit 6c29d5d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

scripts/js/logout.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
document.addEventListener("DOMContentLoaded", () => {
1111
const logoutButton = document.getElementById("logout-button");
12+
const logoutUrl = document.body.dataset.logoutUrl;
13+
1214
logoutButton.addEventListener("click", event => {
1315
event.preventDefault();
14-
utils.doLogout();
16+
utils.doLogout(logoutUrl);
1517
});
1618
});

scripts/js/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,12 @@ function changeBulkDeleteStates(table) {
463463
}
464464
}
465465

466-
function doLogout() {
466+
function doLogout(url) {
467467
$.ajax({
468468
url: apiUrl + "/auth",
469469
method: "DELETE",
470470
}).always(function () {
471-
location.reload();
471+
globalThis.location = url;
472472
});
473473
}
474474

scripts/lua/header_authenticated.lp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mg.include('header.lp','r')
2222
<script defer src="<?=pihole.fileversion('vendor/bstreeview/bstreeview.min.js')?>"></script>
2323
<script defer src="<?=pihole.fileversion('scripts/js/logout.js')?>"></script>
2424
</head>
25-
<body class="<?=theme.name?> hold-transition sidebar-mini <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in" data-apiurl="<?=pihole.api_url()?>">
25+
<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'?>">
2626
<noscript>
2727
<!-- JS Warning -->
2828
<div>

0 commit comments

Comments
 (0)