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

369
Visualizações
How to verify email in firebase auth?

I am using expo client for my app. When I send the email, the verification immediately fails. When I go to the email and verify it, the verification still doesn't work. This is my function:

firebase.auth().createUserWithEmailAndPassword(emailID, password)
    .then(async ({
        user
    }) => {
        //console.log(this.state)
        await user.sendEmailVerification().then(async () => {
            user = await firebase.auth().currentUser;

            await user.reload();

            user = await firebase.auth().currentUser;
            if (user.emailVerified) {
                db.collection("Users").add({
                    'firstName': this.state.firstName,
                    'lastName': this.state.lastName,
                    'contact': this.state.contact,
                    'emailID': this.state.emailID,
                    'password': this.state.password,
                    'description': '',
                    'profilePicture': ''
                })
                return alert('Account has been created. You can now login.');
            } else {
                return alert('Failed to verify email!')
            }
        })
    })
    .catch((error) => {
        // Handle Errors here.
        var errorCode = error.code;
        var errorMessage = error.message;
        return alert(errorMessage);
    });

Can anyone please provide me a solution for this? Thanks,

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The code in your inner then block looks good, but it runs only once: immediately after you sent the verification email.

When you call sendEmailVerification that merely sends the email. Only once you click the link in that email will the email address on the profile be set to verify.

So you will need to re-sign in, or call user.reload(), after clicking the link in order to get the profile with the updated verification status. This means you'll typically run the code that you have in then then block:

  • When the app regains the focus, as often the user needs to toggle to another app to click the verification link, so when the app regains focus is a good moment to check the verification status again.
  • Tell the user to click a button to recheck the verification status.
  • Periodically (say every few second) run the check.

You can pick one of these, but also use any combination of them to ensure the verification status gets picked up quickly in your app.

about 4 years ago · Juan Pablo Isaza Relatório
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