Automatically redirect unauthenticated users to the login page

Implement automatic redirection to the authentication page for unauthenticated users, both client-side and for API 401 responses, to prevent access to protected routes or data.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/7c468936-2a88-4686-ac0a-84921a45222d/jxMXcbq
This commit is contained in:
michaelschal committed 2025-08-13 21:28:29 +00:00
1 parent 0d903315e8
commit f42379b330
2 files changed
+24 -1

No files matched your search

@@ -54,6 +54,20 @@ function RouterProduction() {
}
if (!isAuthenticated) {
// Redirection automatique vers la page d'authentification
if (typeof window !== 'undefined' && window.location.pathname !== '/auth') {
console.log('🔄 User not authenticated, redirecting to auth page');
window.location.href = '/auth';
return (
<div className="min-h-screen w-full flex items-center justify-center bg-surface">
<div className="text-center">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"></div>
<p className="text-gray-600">Redirection...</p>
</div>
</div>
);
}
return (
<Switch>
<Route path="/auth" component={AuthPage} />