Fix: hide auth screen immediately on load if token exists, preventing login flash

This commit is contained in:
Daniel Onyejesi 2026-03-22 00:31:49 -04:00
parent 0c2d3398e0
commit 393cb3f1e0
2 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,6 @@
services:
pediatric-scribe:
image: danielonyejesi/pediatric-ai-scribe-v3:v1.3
image: danielonyejesi/pediatric-ai-scribe-v3:v1.4
ports:
- "3552:3000"
env_file:

View file

@ -27,7 +27,8 @@ document.addEventListener('DOMContentLoaded', function() {
// Check for saved session
var savedToken = localStorage.getItem(TOKEN_KEY);
if (savedToken) {
console.log('[Auth] Found saved token, verifying...');
// Hide auth screen immediately to prevent flash while verifying token
authScreen.classList.add('hidden');
fetch('/api/auth/me', {
headers: { 'Authorization': 'Bearer ' + savedToken }
})
@ -37,15 +38,14 @@ document.addEventListener('DOMContentLoaded', function() {
})
.then(function(data) {
if (data && data.user) {
console.log('[Auth] Token valid, logging in as:', data.user.email);
enterApp(data.user, savedToken);
} else {
console.log('[Auth] Token invalid');
authScreen.classList.remove('hidden');
clearSession();
}
})
.catch(function() {
console.log('[Auth] Token expired or invalid');
authScreen.classList.remove('hidden');
clearSession();
});
}