Describe the bug
According to firebase auth doc, the default behavior of firebase auth persistency is LOCAL meaning it should persistent across refresh. However, that's not the case with firebase_auth_web.
Setting the persistency manually did help either:
To Reproduce
Steps to reproduce the behavior:
firebase_auth for web appExpected behavior
Users should still be signed in after refreshing the tab.
Additional context
Fun fact: it persists during development, but not when the app is compiled.
I have found the solution:
Instead of this:
await _firebaseAuth.currentUser();
use this:
await _firebaseAuth.onAuthStateChanged.first;
Hi @tianhaoz95
does the proposed solution works for you?
If doesn't can you please provide
your flutter doctor -v ,
your flutter run --verbose
and your pubspec.yaml
or if possible a reproducible minimal code sample.
Thank you
@iapicca yes it worked for me. You can probably mark as fixed if that is the suggested approach.
This is a bug if the implementations of the platform interfaces have different results.
Just checked and the JavaScript SDK treats it as a property: https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/auth.js#L928
I think we should update the getCurrentUser function to track the initialization and use the fix above to wait for the first authChanged response whilst the library is still initializing.
lgtm
@iapicca what is left in this issue? Do we want to use it as a tracking bug for the JS SDK fix?
Hi @tianhaoz95
I think you are right, thanks for letting me know
@slightfoot is it ok for you if I close this?
This fix cannot be put in the JS SDK. Assign this ticket to me.
any updates on this issue ?
Updates on this?
@joaquini Maybe this is fixed with 0.18.0, because they made a complete rework of firebase_auth. Have tried it with the new version?
Hey 馃憢
The rework of the firebase_auth plugin as part of the FlutterFire roadmap was published over a week ago with a ton of fixes and new features. Please could you try the new version and see if this is still an issue for you? If it is then please submit a new up to date GitHub issue.
We also added support on web for configuring persistence, see: https://firebase.flutter.dev/docs/auth/usage#persisting-authentication-state
For help migrating to the new plugins please see the new migration guide: https://firebase.flutter.dev/docs/migration
Most helpful comment
This fix cannot be put in the JS SDK. Assign this ticket to me.