firebase-tools-ui icon indicating copy to clipboard operation
firebase-tools-ui copied to clipboard

Editing user via Emulator UI seems to invalidate the user token.

Open rickwillcox opened this issue 3 years ago • 1 comments

Edit: Just noticed that changing any property on this form results in invalidating the user-token image

[REQUIRED] Environment info

firebase tools --version 11.8.0

Linux mint

[REQUIRED] Test case

  async function checkForUserVerification() {
    await reload(auth.currentUser);
    console.log('user: ', auth.currentUser);
    if (!auth.currentUser?.emailVerified) {
      setTimeout(checkForUserVerification, 1500);
    } else {
      console.log('user verified');
    }
  }
  useEffect(() => {
    checkForUserVerification();
  }, []);

[REQUIRED] Steps to reproduce

When using firebase emulator if I manually set the email to verified using the gui provided I get this error

index-69ab4e3a.js:474 Uncaught (in promise) FirebaseError: Firebase: Error (auth/user-token-expired).
    at createErrorInternal (index-69ab4e3a.js:474:1)
    at _fail (index-69ab4e3a.js:445:1)
    at _performFetchWithErrorHandling (index-69ab4e3a.js:976:1)
    at async _logoutIfInvalidated (index-69ab4e3a.js:1213:1)
    at async _reloadWithoutSaving (index-69ab4e3a.js:1371:1)
    at async reload (index-69ab4e3a.js:1410:1)

However when I use the real firebase server the code works as expected.

[REQUIRED] Expected behavior

when I set email to verified in firebase emulator gui the user verified should log.

[REQUIRED] Actual behavior

when I do above I get that error above. My code works perfectly as far as I can tell using a real firebase server instead of emulator.

rickwillcox avatar Sep 23 '22 07:09 rickwillcox

Hey @RickWillcox, thanks for filing this issue. I was able to repro the issue - triggering refresh() after any user edits via the Emulator UI results in the same error and signs out the current user. I suspect it's an issue isolated to the Emulator UI as opposed to the Emulator itself, since calling any of the Emulator endpoints directly to update the User fields does not trigger this error. I'm also able to repro this issue in Firebase CLI v10.9.2.

We are unable to promise any timeline for this, but if others also have this issue, adding a +1 on this issue can help us prioritize adding this to the roadmap. (Googler-only internal tracking bug: b/248492359)

lisajian avatar Oct 04 '22 00:10 lisajian