Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

278
Vistas
Firebase signInWithCredential does not throw error with wrong credential

I am using React Native with Expo. I'm trying to create phone authentication for my app using Firebase and the following function should throw an error according to the signInWithCredential documentation if you put a wrong verificationCode. However the function just logs a null user value and throws no 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);
}};

I use the following code to send the verificationCode:

  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);
}};

If you input the right verificationCode the function still logs a null user value but then this function sets the right user value afterwards

auth.onAuthStateChanged((foundUser) => {
if (foundUser) {
  setUser(foundUser);
  console.log("Found user and set it");
}});

Can someone see what my error is?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda