From f42379b330aeb4dcd566ad627d09b9c7b3159eeb Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Wed, 13 Aug 2025 21:28:29 +0000 Subject: [PATCH] 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 --- client/src/components/RouterProduction.tsx | 14 ++++++++++++++ client/src/lib/queryClient.ts | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/client/src/components/RouterProduction.tsx b/client/src/components/RouterProduction.tsx index 53f7a54..6a7506f 100644 --- a/client/src/components/RouterProduction.tsx +++ b/client/src/components/RouterProduction.tsx @@ -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 ( +
Redirection...
+