Fix: hide auth screen immediately on load if token exists, preventing login flash
This commit is contained in:
parent
0c2d3398e0
commit
393cb3f1e0
2 changed files with 5 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
services:
|
services:
|
||||||
pediatric-scribe:
|
pediatric-scribe:
|
||||||
image: danielonyejesi/pediatric-ai-scribe-v3:v1.3
|
image: danielonyejesi/pediatric-ai-scribe-v3:v1.4
|
||||||
ports:
|
ports:
|
||||||
- "3552:3000"
|
- "3552:3000"
|
||||||
env_file:
|
env_file:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Check for saved session
|
// Check for saved session
|
||||||
var savedToken = localStorage.getItem(TOKEN_KEY);
|
var savedToken = localStorage.getItem(TOKEN_KEY);
|
||||||
if (savedToken) {
|
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', {
|
fetch('/api/auth/me', {
|
||||||
headers: { 'Authorization': 'Bearer ' + savedToken }
|
headers: { 'Authorization': 'Bearer ' + savedToken }
|
||||||
})
|
})
|
||||||
|
|
@ -37,15 +38,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
})
|
})
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
if (data && data.user) {
|
if (data && data.user) {
|
||||||
console.log('[Auth] Token valid, logging in as:', data.user.email);
|
|
||||||
enterApp(data.user, savedToken);
|
enterApp(data.user, savedToken);
|
||||||
} else {
|
} else {
|
||||||
console.log('[Auth] Token invalid');
|
authScreen.classList.remove('hidden');
|
||||||
clearSession();
|
clearSession();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function() {
|
.catch(function() {
|
||||||
console.log('[Auth] Token expired or invalid');
|
authScreen.classList.remove('hidden');
|
||||||
clearSession();
|
clearSession();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue