Auto-reload on auth timeout (401 response)
Wrap window.fetch so any 401 triggers window.location.reload(), sending the browser back through the Authelia proxy to the login page. Covers all pages since app.js is loaded by base.html. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// ── Auto-redirect on auth timeout ─────────────────────────────────────
|
||||||
|
// Intercept all fetch() calls: if the server returns 401 (auth expired),
|
||||||
|
// reload the page so Authelia redirects to the login screen.
|
||||||
|
(function () {
|
||||||
|
const _fetch = window.fetch;
|
||||||
|
window.fetch = async function (...args) {
|
||||||
|
const resp = await _fetch(...args);
|
||||||
|
if (resp.status === 401) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
return resp;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
// ── Toast notifications — delegates to lt.toast from base.js ─────────
|
// ── Toast notifications — delegates to lt.toast from base.js ─────────
|
||||||
function showToast(msg, type = 'success') {
|
function showToast(msg, type = 'success') {
|
||||||
if (type === 'error') return lt.toast.error(msg);
|
if (type === 'error') return lt.toast.error(msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user