Skip to content

Commit 345d271

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 877d5f8 commit 345d271

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 = logoutButton.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
@@ -87,7 +87,7 @@ mg.include('header.lp','r')
8787
<a class="btn-link" href="https://github.com/pi-hole" rel="noopener" target="_blank"><i class="fa-fw menu-icon fab fa-github"></i> GitHub</a>
8888
<a class="btn-link" href="https://discourse.pi-hole.net/c/announcements/5" rel="noopener" target="_blank"><i class="fa-fw menu-icon fa-solid fa-rocket"></i> Pi-hole Releases</a>
8989
<? if pihole.needLogin() then ?>
90-
<a class="btn-link" href="#" id="logout-button"><i class="fa-fw menu-icon fa-solid fa-arrow-right-from-bracket"></i> Log out</a>
90+
<a class="btn-link" href="#" id="logout-button" data-logout-url="<?=pihole.webhome() .. 'login'?>"><i class="fa-fw menu-icon fa-solid fa-arrow-right-from-bracket"></i> Log out</a>
9191
<? end ?>
9292
</li>
9393
</ul>

0 commit comments

Comments
 (0)