Estoy usando React Native con Expo. Estoy tratando de crear una autenticación de teléfono para mi aplicación usando Firebase y la siguiente función debería arrojar un error de acuerdo con la documentación signInWithCredential si coloca un código de verificación incorrecto. Sin embargo, la función simplemente registra un valor de usuario nulo y no arroja ningún error.
const confirmPhoneVCode = async () => { try { const credential = PhoneAuthProvider.credential( verificationId, verificationCode ); // Sets the user variable await setUser(signInWithCredential(auth, credential).user); console.log(user); console.log("phone auth worked with user"); } catch (err) { console.log(err); }};Yo uso el siguiente código para enviar el código de verificación:
const sendPhoneVCode = async () => { // The FirebaseRecaptchaVerifierModal ref implements the // FirebaseAuthApplicationVerifier interface and can be // passed directly to `verifyPhoneNumber`. try { const phoneProvider = new PhoneAuthProvider(auth); const verificationId = await phoneProvider.verifyPhoneNumber( phoneNumber, recaptchaVerifier.current ); setVerificationId(verificationId); console.log("Send to phone"); } catch (err) { console.log(err); }};Si ingresa el código de verificación correcto, la función aún registra un valor de usuario nulo, pero luego esta función establece el valor de usuario correcto
auth.onAuthStateChanged((foundUser) => { if (foundUser) { setUser(foundUser); console.log("Found user and set it"); }});¿Alguien puede ver cuál es mi error?