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

366
Visualizações
firebase email verification issue

Is there a method to verify whether or not an email address has been verified before logging in? Using the firebase authentication hooks "useCreateUserWithEmailAndPassword", I'm sending verification links to the email. It's working perfect. However, I want to verify the email address. The user is already logged in, even if he does not check his email. I want the user to confirm their email address the he'll be logged in.

const navigate = useNavigate(); const [ createUserWithEmailAndPassword, user, loading, error, ] = useCreateUserWithEmailAndPassword(auth, {sendEmailVerification: true});

`const handleSubmit = event => {
    event.preventDefault();
    const email = event.target.email.value;
    const password = event.target.password.value;
    createUserWithEmailAndPassword(email, password);
    console.log(email, password);
}` 
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Anyone can use a fake email to log in and visit a protected route. But you can manage this by email verification. Not only just log in, they have to verify their email also and only after this they can visit the protected route. To implement this, set an email verification condition. Here's the code:

const RequireAuth = ({ children }) => {
const [sendEmailVerification] = useSendEmailVerification(auth);
const [user, loading] = useAuthState(auth);
const location = useLocation();

if (loading) {
   return <Spinner animation='border' variant='primary'></Spinner>
}

if (!user) {
   return <Navigate to='/signIn' state={{ from: location }} replace></Navigate>
}

if (!user?.emailVerified) {
    return (
        <div className='w-50 my-5 mx-auto'>
            <h2 className='text-danger'>Your Email is not verified</h2>
            <Button onClick={async () => sendEmailVerification()} variant="primary">Verify your email</Button>
        </div>
    )
}
return children;
about 4 years ago · Juan Pablo Isaza Relatório

0

Take a useState and initialised it with user come from useAuthState.and then load data to ui. and then check emailVerified.if its true then you can show it ui to the user to check email

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