Skip to content

Commit 0a33b78

Browse files
committed
Alternative approach
Signed-off-by: XhmikosR <[email protected]>
1 parent 9ee0a7a commit 0a33b78

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

scripts/js/logout.js

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

1010
document.addEventListener("DOMContentLoaded", () => {
1111
const logoutButton = document.getElementById("logout-button");
12-
logoutButton.addEventListener("click", event => {
12+
const logoutUrl = logoutButton.dataset.logoutUrl;
13+
logoutButton.addEventListener("click", () => {
1314
event.preventDefault();
14-
utils.doLogout();
15+
utils.doLogout(logoutUrl);
1516
});
1617
});

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: "/api/auth",
469469
method: "DELETE",
470470
}).always(function () {
471-
globalThis.location = "/admin/login";
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)