Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda