Improve demo tennat and user get

This commit is contained in:
Urtzi Alfaro
2026-01-17 09:19:42 +01:00
parent 4b65817b3e
commit fbc670ddb3
9 changed files with 225 additions and 88 deletions

View File

@@ -72,9 +72,19 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
}
}
} else if (authStore.isAuthenticated) {
// User is marked as authenticated but no tokens, logout
console.log('No tokens found but user marked as authenticated, logging out');
authStore.logout();
// User is marked as authenticated but no tokens
// Check if this is a demo session - demo sessions don't use JWT tokens
const isDemoMode = localStorage.getItem('demo_mode') === 'true';
const demoSessionId = localStorage.getItem('demo_session_id');
if (isDemoMode && demoSessionId) {
// Demo session: authentication is valid via X-Demo-Session-Id header
console.log('Demo session detected, maintaining authentication state');
} else {
// Regular user without tokens - logout
console.log('No tokens found but user marked as authenticated, logging out');
authStore.logout();
}
} else {
console.log('No stored auth data found');
}