Skip to content

Commit 2bc67f3

Browse files
Fix: Infinite loading on login page
Investigated and addressed the infinite loading issue on the login page, likely related to authentication or initialization issues.
1 parent 0bf3cd3 commit 2bc67f3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/hooks/useAuth.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,28 @@ import { useRetry } from './useRetry';
1414

1515
export const useAuth = () => {
1616
const [user, setUser] = useState<User | null>(null);
17-
const [loading, setLoading] = useState(true);
17+
const [loading, setLoading] = useState(false);
1818
const [initialized, setInitialized] = useState(false);
1919
const { handleError } = useErrorHandler();
2020
const { executeWithRetry } = useRetry({ maxRetries: 2 });
2121

2222
useEffect(() => {
2323
console.log('🔐 Initialisation de l\'authentification...');
2424

25+
// Marquer comme initialisé immédiatement pour éviter les blocages
26+
setInitialized(true);
27+
2528
const unsubscribe = onAuthStateChanged(auth, (user) => {
2629
console.log('🔐 État d\'authentification changé:', user ? 'Connecté' : 'Déconnecté');
2730
setUser(user);
2831
setLoading(false);
29-
setInitialized(true);
3032
}, (error) => {
3133
console.error('🚨 Erreur d\'authentification:', error);
3234
handleError(error, {
3335
showToast: true,
3436
logError: true
3537
});
3638
setLoading(false);
37-
setInitialized(true);
3839
});
3940

4041
return unsubscribe;

src/pages/Index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { Dashboard } from '@/components/Dashboard';
55
import { useTranslation } from 'react-i18next';
66

77
const Index = () => {
8-
const { user, loading, initialized } = useAuth();
8+
const { user, loading } = useAuth();
99
const { t } = useTranslation();
1010

11-
console.log('🔍 Index render - user:', !!user, 'loading:', loading, 'initialized:', initialized);
11+
console.log('🔍 Index render - user:', !!user, 'loading:', loading);
1212

13-
// Pendant l'initialisation de Firebase
14-
if (!initialized || loading) {
13+
// Affichage immédiat - pas d'attente d'initialisation
14+
if (loading) {
1515
return (
1616
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50/50 via-white to-purple-50/50">
1717
<div className="text-center">

0 commit comments

Comments
 (0)