Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!