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

161
Visualizações
Firebase - onAuthStateChanged() fires both after sign in and sign up

I need to be able to figure out why did the listener fire - was it an initial sign up or sign in?

I tried using part of the user payload that comes with the callback. I tried comparing user.metadata.createdAt and user.metadata.lastLoginAt and this usually works - if I sign up, then sign out, and then sign in - it's all ok. But it is not ok when I sign up and then simply refresh the page.

Is there a way to see some metadata about when was the last time the auth status was changed or simple - to figure out if onAuthStateChanged fired because of a sign up or sign in.

Thanks!

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

0

The onAuthStateChanged() fires when the auth state changes, so that is indeed both for sign-ups and sign-ins.

If you want to distinguish between the two, you can:

  • Either hook the explicit then that you get back from the signIn.../createUser method.
  • Or you can compare the creationTime and lastSignInTime in the user.metadata. If they're the same, the user was just created.
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