From c27a7833887a6380329c1bb8a2a9e846f7e3cd78 Mon Sep 17 00:00:00 2001 From: Chris Christiansen Date: Wed, 24 Jun 2026 14:46:52 +0000 Subject: [PATCH] fix: auth/me check on load --- static/opax.html | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/static/opax.html b/static/opax.html index 41ffb8d..7fa32b4 100644 --- a/static/opax.html +++ b/static/opax.html @@ -794,9 +794,22 @@ async function pollBuild(){ return null } } -document.addEventListener('DOMContentLoaded', () => { +document.addEventListener('DOMContentLoaded', async () => { + // Sjekk auth-status + try { + const r = await fetch('/auth/me') + if(r.ok){ + const u = await r.json() + document.getElementById('sb-session').textContent = u.email || 'innlogget' + document.getElementById('send-btn').disabled = false + } else { + window.location.href = '/auth/login' + } + } catch(e) { + document.getElementById('sb-session').textContent = 'session: feil' + } pollBuild() - setInterval(pollBuild,30000) + setInterval(pollBuild, 30000) }) // ─── Fix 3: CostGuard — fetchWithTimeout helper (AbortController, 10s) ───