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

159
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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