@@ -19,10 +19,14 @@ export const useAuth = () => {
1919 const { executeWithRetry } = useRetry ( { maxRetries : 2 } ) ;
2020
2121 useEffect ( ( ) => {
22+ console . log ( '🔐 Initialisation de l\'authentification...' ) ;
23+
2224 const unsubscribe = onAuthStateChanged ( auth , ( user ) => {
25+ console . log ( '🔐 État d\'authentification changé:' , user ? 'Connecté' : 'Déconnecté' ) ;
2326 setUser ( user ) ;
2427 setLoading ( false ) ;
2528 } , ( error ) => {
29+ console . error ( '🚨 Erreur d\'authentification:' , error ) ;
2630 handleError ( error , {
2731 showToast : true ,
2832 logError : true
@@ -34,45 +38,57 @@ export const useAuth = () => {
3438 } , [ handleError ] ) ;
3539
3640 const signInWithEmail = async ( email : string , password : string ) => {
41+ console . log ( '🔐 Tentative de connexion avec email:' , email ) ;
3742 try {
38- await executeWithRetry (
43+ const result = await executeWithRetry (
3944 ( ) => signInWithEmailAndPassword ( auth , email , password ) ,
4045 { component : 'useAuth' , action : 'signInWithEmail' }
4146 ) ;
47+ console . log ( '✅ Connexion réussie:' , result . user . uid ) ;
4248 } catch ( error ) {
43- throw error ; // L'erreur a déjà été gérée par executeWithRetry
49+ console . error ( '❌ Erreur de connexion:' , error ) ;
50+ throw error ;
4451 }
4552 } ;
4653
4754 const signUpWithEmail = async ( email : string , password : string ) => {
55+ console . log ( '🔐 Tentative de création de compte avec email:' , email ) ;
4856 try {
49- await executeWithRetry (
57+ const result = await executeWithRetry (
5058 ( ) => createUserWithEmailAndPassword ( auth , email , password ) ,
5159 { component : 'useAuth' , action : 'signUpWithEmail' }
5260 ) ;
61+ console . log ( '✅ Compte créé:' , result . user . uid ) ;
5362 } catch ( error ) {
63+ console . error ( '❌ Erreur de création de compte:' , error ) ;
5464 throw error ;
5565 }
5666 } ;
5767
5868 const signInWithGoogle = async ( ) => {
69+ console . log ( '🔐 Tentative de connexion avec Google' ) ;
5970 try {
60- await executeWithRetry (
71+ const result = await executeWithRetry (
6172 ( ) => signInWithPopup ( auth , googleProvider ) ,
6273 { component : 'useAuth' , action : 'signInWithGoogle' }
6374 ) ;
75+ console . log ( '✅ Connexion Google réussie:' , result . user . uid ) ;
6476 } catch ( error ) {
77+ console . error ( '❌ Erreur de connexion Google:' , error ) ;
6578 throw error ;
6679 }
6780 } ;
6881
6982 const logout = async ( ) => {
83+ console . log ( '🔐 Tentative de déconnexion' ) ;
7084 try {
7185 await executeWithRetry (
7286 ( ) => signOut ( auth ) ,
7387 { component : 'useAuth' , action : 'logout' }
7488 ) ;
89+ console . log ( '✅ Déconnexion réussie' ) ;
7590 } catch ( error ) {
91+ console . error ( '❌ Erreur de déconnexion:' , error ) ;
7692 throw error ;
7793 }
7894 } ;
0 commit comments