Added isAuthReady state to prevent router from rendering before auth state is initialized. This eliminates login redirect loops and ensures deterministic auth behavior. Changes: - Added isAuthReady state (default: false) - New useEffect to initialize auth before rendering - Waits for refreshUser() to complete if tokens exist - Shows loading screen while auth is initializing - Always sets isAuthReady=true in finally block Loading screen: - Simple centered spinner with "Chargement..." text - Uses Tailwind classes for styling - Matches app theme (bg-background, text-muted-foreground) Behavior: - App loads → Check for tokens → If yes, await refreshUser() - Only after auth check completes, render router - Prevents "flash of login page" for authenticated users - Eliminates race condition: router no longer renders before auth ready Impact: Fixes intermittent login loops, improves UX on page refresh. Fixes: P1.2 from audit AUDIT_TEMP_29_01_2026.md |
||
|---|---|---|
| .. | ||
| App.tsx | ||