some fixes to the auth and lockouts

This commit is contained in:
2025-08-27 08:54:22 -06:00
parent a8edcf8592
commit f28ed7cad0
13 changed files with 54 additions and 369 deletions

View File

View File

View File

View File

View File

View File

View File

View File

@@ -96,6 +96,17 @@ function setupAutoRefresh() {
refreshInterval = setInterval(async () => {
try {
// Check if user is still authenticated
const authResponse = await fetch('/api/auth/check');
const authData = await authResponse.json();
if (!authData.authenticated) {
// Stop auto-refresh if not authenticated
clearInterval(refreshInterval);
console.log('Auto-refresh stopped - user not authenticated');
return;
}
await loadLocations();
consecutiveErrors = 0; // Reset error count on success
} catch (error) {
@@ -111,6 +122,17 @@ function setupAutoRefresh() {
const slowInterval = refreshInterval_ms * 2; // Double the interval
refreshInterval = setInterval(async () => {
try {
// Check if user is still authenticated
const authResponse = await fetch('/api/auth/check');
const authData = await authResponse.json();
if (!authData.authenticated) {
// Stop auto-refresh if not authenticated
clearInterval(refreshInterval);
console.log('Auto-refresh stopped - user not authenticated');
return;
}
await loadLocations();
consecutiveErrors = 0;
} catch (error) {

View File

@@ -126,3 +126,16 @@ export function setViewportDimensions() {
}
}
}
// Add session expiry detection
function handleAuthError(error) {
if (error.status === 401) {
// Stop all intervals
if (typeof autoRefreshInterval !== 'undefined') {
clearInterval(autoRefreshInterval);
}
// Redirect to login with expiry message
window.location.href = '/login.html?expired=true';
}
}