Skip to content

🐛 [flutterfire_ui] Auth: Profile screen does not rebuild after email verification status changes. #8683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neiljaywarner opened this issue May 13, 2022 · 8 comments
Assignees
Labels
plugin: ui resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working

Comments

@neiljaywarner
Copy link

Email auth has a "waiting for email" with a spinner on the profile screen.

Expected behaviour:

  1. background app
  2. go to emamil, click on verify, observe success message, background email
  3. Return to app from recents menu
  4. Observe waiting and profile vanish

Actual behaviour:
Signing out and signing back in causes it to vanish.
Note: I'm on flutter UI flutterfire_ui: 0.4.0+5 because 0.4.1 seems to require flutter 3.

@neiljaywarner neiljaywarner added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels May 13, 2022
@neiljaywarner neiljaywarner changed the title 🐛 [flutterfire_ui] Auth 🐛 [flutterfire_ui] Auth: Profile screen does not rebuild after email verification status changes. May 13, 2022
@darshankawar darshankawar added the triage Issue is currently being triaged. label May 16, 2022
@darshankawar
Copy link

@neiljaywarner
Is this happening on Android or iOS ?
Does the same behavior occur using plugin's example too ?

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels May 16, 2022
@neiljaywarner
Copy link
Author

neiljaywarner commented May 16, 2022 via email

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels May 16, 2022
@BrutalCoding
Copy link
Contributor

BrutalCoding commented May 17, 2022

I've made this "Waiting for email verification" screen myself. I discovered that this is an issue with Firebase Auth, the FirebaseAuth.instance.authStateChanges() stream does not fire when the emailVerified flag gets changed on your Firebase Auth profile. Nor does it fire by using FirebaseAuth.instance.userChanges() and even FirebaseAuth.instance.idTokenChanges(). None of the FirebaseAuth streams get fired when the emailVerified flag gets changed.

My solution was to create a looping timer (e.g. every 10 seconds) and call "FirebaseAuth.instance.currentUser?.reload();".

Here's an example:
@override void initState() { super.initState(); _timer = Timer.periodic(const Duration(seconds: 10), (timer) { FirebaseAuth.instance.currentUser?.reload(); }); }

Make sure you define Timer _timer in your statefulwidget and don't forget to cancel the timer when the e-mail has been verified.

By forcing the ...currentUser?.reload() method, the FirebaseAuth.instance.userChanges() stream will get triggered and the User object you get back from that stream will have an up-to-date emailVerified boolean. E.g. this will work: user?.emailVerified == true.

@darshankawar
Copy link

@BrutalCoding
Thanks for the update. Can you open a new issue mentioning all these details so that we can track and address it properly and possibly link this issue to it as a reference, because per your comment / findings, the issue probably lies in firebase_auth and may not be specific to flutterfire_ui plugin since it seems to leverage the auth implementation.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels May 17, 2022
@Patrick386
Copy link

I also agree with this issue.
You should be able to check the emailVerified status with reload() .

@BrutalCoding
Copy link
Contributor

BrutalCoding commented May 26, 2022

@BrutalCoding Thanks for the update. Can you open a new issue mentioning all these details so that we can track and address it properly and possibly link this issue to it as a reference, because per your comment / findings, the issue probably lies in firebase_auth and may not be specific to flutterfire_ui plugin since it seems to leverage the auth implementation.

Thanks for the suggestion, I have opened a new issue here #8777 and described it in more detail.

I personally think that its not only Flutter's firebase_auth package that is affected by this, but it might be a widespread issue with all Firebase Auth SDK's. The reason I say this is because Firebase Auth for JavaScript faces the same issue: https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#onauthstatechanged

@darshankawar darshankawar removed blocked: customer-response Waiting for customer response, e.g. more information was requested. triage Issue is currently being triaged. labels May 26, 2022
@lesnitsky lesnitsky added this to the [UI] Stable release milestone Sep 16, 2022
@guplem
Copy link

guplem commented Oct 6, 2022

I wanted to bring some attention to more issues related to the ProfileScreen not rebuilding with #9682. Maybe it is related.

@lesnitsky
Copy link
Member

fixed in #9343

@darshankawar darshankawar added the resolution: fixed A fix has been merged or is pending merge from a PR. label Oct 18, 2022
@firebase firebase locked and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: ui resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants