7

I have following flow for my sign up process:

  1. User fills out details and signs up (gets send verification email)

  2. After this user is logged in, but sees a screen asking to for email verification

  3. User verifies their email and goes back to app

At this stage how can I get new user data that will have emailVerified field without logging user out?

I expected auth().onAuthStateChanged to be fired once emailVerified changes to true, but that does not happen, nor can I find any refresh function in firebase docs to get this data manually.

Only way I can get that new value for emailVerified is by loging out and loging back in, but ideally would like to avoid this.


update: this is using JavaScript SDK

Sara Fuerst
  • 5,688
  • 8
  • 43
  • 86
Ilja
  • 44,142
  • 92
  • 275
  • 498
  • There is a known issue in version 9.8-10.0 of the Firebase SDK for Android that means it only updates the user profile when you sign in. Until that is fixed (I don't know when the release is out), there is no solution. Workarounds: stick to 9.6 or to sign-out/sign-in. – Frank van Puffelen Jan 26 '17 at 13:52
  • See http://stackoverflow.com/questions/40723639/firebaseusers-profile-is-not-updated and http://stackoverflow.com/questions/41651454/update-to-authdata/41652179#41652179 – Frank van Puffelen Jan 26 '17 at 13:53
  • @FrankvanPuffelenoh my bad, I updated the question this is for latest (3.6.7) javascript sdk – Ilja Jan 26 '17 at 13:54
  • Ah hold on, that's completely different. Not sure what the case is there. – Frank van Puffelen Jan 26 '17 at 13:54
  • Calling `auth().currentUser` also returns old user information after verifying email successfully @FrankvanPuffelen I have to perform page refresh to get new details or re-authenticate – Ilja Jan 26 '17 at 13:59
  • 1
    `currentUser.getToken(true)` makes onAuthStateChanged fire but returned user object still doesn't have updated emailVerified field – Ilja Jan 26 '17 at 14:07
  • 1
    @llja Did you figure this out? – Jasmeet Nov 19 '19 at 16:20

1 Answers1

7

Based on android I did

firebase.auth().currentUser.reload().then(() => {
  console.log(firebase.auth().currentUser)
})

this returns updated information about the user, I couldn't find this anywhere in the docs for some reason

Ilja
  • 44,142
  • 92
  • 275
  • 498