fix: auth/me check on load
This commit is contained in:
parent
ea9fadb3e0
commit
c27a783388
|
|
@ -794,7 +794,20 @@ async function pollBuild(){
|
||||||
return null
|
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()
|
pollBuild()
|
||||||
setInterval(pollBuild, 30000)
|
setInterval(pollBuild, 30000)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user