flutterfire
flutterfire copied to clipboard
🐛 [flutterfire_ui] Auth: Profile screen does not rebuild after email verification status changes.
Email auth has a "waiting for email" with a spinner on the profile screen.
Expected behaviour:
- background app
- go to emamil, click on verify, observe success message, background email
- Return to app from recents menu
- 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 Is this happening on Android or iOS ? Does the same behavior occur using plugin's example too ?
Plugins example required many files but authgate code cones from docs.
I didn't try ios
....sent from my phone
On Mon, May 16, 2022, 5:39 AM darshankawar @.***> wrote:
@neiljaywarner https://github.com/neiljaywarner Is this happening on Android or iOS ? Does the same behavior occur using plugin's example too ?
— Reply to this email directly, view it on GitHub https://github.com/firebase/flutterfire/issues/8683#issuecomment-1127507940, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXBGYKJNKIXCHNRKQJN7CLVKIQWFANCNFSM5V4UWZBA . You are receiving this because you were mentioned.Message ID: @.***>
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
.
@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.
I also agree with this issue. You should be able to check the emailVerified status with reload() .
@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 toflutterfire_ui
plugin since it seems to leverage the auth implementation.
Thanks for the suggestion, I have opened a new issue here https://github.com/firebase/flutterfire/issues/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
I wanted to bring some attention to more issues related to the ProfileScreen not rebuilding with #9682. Maybe it is related.
fixed in #9343