error in login
Deploy / deploy (push) Successful in 1m24s

This commit is contained in:
2026-05-07 19:48:25 +02:00
parent 1fdaef7695
commit c7c11df629
4 changed files with 41 additions and 6 deletions
+23 -2
View File
@@ -892,6 +892,10 @@ let currentRole = null;
async function checkSession() {
try {
const res = await fetch('/api/session');
if (res.redirected || !res.ok) {
window.location.replace('/login.php');
return;
}
const data = await res.json();
if (data.loggedin) {
currentUser = data.username;
@@ -901,10 +905,27 @@ async function checkSession() {
document.getElementById('settingsBtn').classList.remove('d-none');
}
} else {
window.location.href = '/login.php';
window.location.replace('/login.php');
}
} catch (e) {
window.location.href = '/login.php';
// Retry once after a brief delay in case of transient network issue
setTimeout(async () => {
try {
const res = await fetch('/api/session');
if (!res.ok || res.redirected) throw new Error();
const data = await res.json();
if (data.loggedin) {
currentUser = data.username;
currentRole = data.role;
document.getElementById('userDisplay').textContent = data.username;
if (data.role === 'admin' || data.admin_count === 0) {
document.getElementById('settingsBtn').classList.remove('d-none');
}
return;
}
} catch (_) {}
window.location.replace('/login.php');
}, 500);
}
}