@@ -9,20 +9,15 @@ import {
99 onAuthStateChanged
1010} from 'firebase/auth' ;
1111import { auth , googleProvider } from '@/lib/firebase' ;
12- import { useErrorHandler } from './useErrorHandler' ;
13- import { useRetry } from './useRetry' ;
1412
1513export const useAuth = ( ) => {
1614 const [ user , setUser ] = useState < User | null > ( null ) ;
1715 const [ loading , setLoading ] = useState ( false ) ;
1816 const [ initialized , setInitialized ] = useState ( false ) ;
19- const { handleError } = useErrorHandler ( ) ;
20- const { executeWithRetry } = useRetry ( { maxRetries : 2 } ) ;
2117
2218 useEffect ( ( ) => {
2319 console . log ( '🔐 Initialisation de l\'authentification...' ) ;
2420
25- // Marquer comme initialisé immédiatement pour éviter les blocages
2621 setInitialized ( true ) ;
2722
2823 const unsubscribe = onAuthStateChanged ( auth , ( user ) => {
@@ -31,22 +26,17 @@ export const useAuth = () => {
3126 setLoading ( false ) ;
3227 } , ( error ) => {
3328 console . error ( '🚨 Erreur d\'authentification:' , error ) ;
34- // Pas besoin d'utiliser handleError ici pour éviter les dépendances
35- console . error ( 'Details:' , error . message ) ;
3629 setLoading ( false ) ;
3730 } ) ;
3831
3932 return unsubscribe ;
40- } , [ ] ) ; // Tableau de dépendances vide pour éviter la boucle infinie
33+ } , [ ] ) ; // Dépendances vides pour éviter les boucles
4134
4235 const signInWithEmail = async ( email : string , password : string ) => {
4336 console . log ( '🔐 Tentative de connexion avec email:' , email ) ;
4437 setLoading ( true ) ;
4538 try {
46- const result = await executeWithRetry (
47- ( ) => signInWithEmailAndPassword ( auth , email , password ) ,
48- { component : 'useAuth' , action : 'signInWithEmail' }
49- ) ;
39+ const result = await signInWithEmailAndPassword ( auth , email , password ) ;
5040 console . log ( '✅ Connexion réussie:' , result . user . uid ) ;
5141 } catch ( error ) {
5242 console . error ( '❌ Erreur de connexion:' , error ) ;
@@ -60,10 +50,7 @@ export const useAuth = () => {
6050 console . log ( '🔐 Tentative de création de compte avec email:' , email ) ;
6151 setLoading ( true ) ;
6252 try {
63- const result = await executeWithRetry (
64- ( ) => createUserWithEmailAndPassword ( auth , email , password ) ,
65- { component : 'useAuth' , action : 'signUpWithEmail' }
66- ) ;
53+ const result = await createUserWithEmailAndPassword ( auth , email , password ) ;
6754 console . log ( '✅ Compte créé:' , result . user . uid ) ;
6855 } catch ( error ) {
6956 console . error ( '❌ Erreur de création de compte:' , error ) ;
@@ -77,10 +64,7 @@ export const useAuth = () => {
7764 console . log ( '🔐 Tentative de connexion avec Google' ) ;
7865 setLoading ( true ) ;
7966 try {
80- const result = await executeWithRetry (
81- ( ) => signInWithPopup ( auth , googleProvider ) ,
82- { component : 'useAuth' , action : 'signInWithGoogle' }
83- ) ;
67+ const result = await signInWithPopup ( auth , googleProvider ) ;
8468 console . log ( '✅ Connexion Google réussie:' , result . user . uid ) ;
8569 } catch ( error ) {
8670 console . error ( '❌ Erreur de connexion Google:' , error ) ;
@@ -94,10 +78,7 @@ export const useAuth = () => {
9478 console . log ( '🔐 Tentative de déconnexion' ) ;
9579 setLoading ( true ) ;
9680 try {
97- await executeWithRetry (
98- ( ) => signOut ( auth ) ,
99- { component : 'useAuth' , action : 'logout' }
100- ) ;
81+ await signOut ( auth ) ;
10182 console . log ( '✅ Déconnexion réussie' ) ;
10283 } catch ( error ) {
10384 console . error ( '❌ Erreur de déconnexion:' , error ) ;
0 commit comments