Improve demo tennat and user get
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user