Skip to content
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

[firebase_auth_web] Credentials Persistence #1771

Closed
rdev-software opened this issue Jan 6, 2020 · 4 comments
Closed

[firebase_auth_web] Credentials Persistence #1771

rdev-software opened this issue Jan 6, 2020 · 4 comments
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) type: enhancement New feature or request

Comments

@rdev-software
Copy link

On page reload I am loosing currentUser, there is no persistence present ?

@rich-j
Copy link

rich-j commented Jan 24, 2020

The issue as we see it is that the web and iOS/Android versions behave differently. During iOS restart, restoring the user from a previous session with await firebaseAuth.currentUser() just works - and you get a null if there wasn't a previous user session to restore. During a web restart, the same code always returns null even when there was a previous user session. It would be nice for the Dart Firebase API to behave consistently across platforms.

Since we have other state that tells us that we do have a user, we wait for the state to change:

final maybeUser = await firebaseAuth.onAuthStateChanged
  .timeout(Duration(seconds:5))       // Throws TimeoutException on expiration
  .firstWhere( (user) => user != null )
  .then( (user) => Some( user ) )
  .catchError( (_) => None() );

Note that this code is waiting on Firebase authentication internal initialization to occur. Since currentUser returns a Future it should return a value that includes the knowledge that initialization has completed. The FirebaseApp.configure also returns a Future that could take in to account internal initialization being completed.

using firebase_auth: 0.15.3+1 which brings in firebase_auth_web 0.1.1+4

Flutter (Channel beta, v1.13.6, on Mac OS X 10.15.2 19C57, locale en-US)

@iapicca iapicca added the type: enhancement New feature or request label Jan 30, 2020
@iapicca iapicca added the impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) label Mar 6, 2020
@Yacine-Benali
Copy link

any updates on this issue ?

@matthewp672261
Copy link

Curious on this too. Seems inconsistent in it's implementation.

@Salakar
Copy link
Member

Salakar commented Aug 25, 2020

Hey 👋

Our 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.

Support for changing persistence settings was added, 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

@Salakar Salakar closed this as completed Aug 25, 2020
@firebase firebase locked and limited conversation to collaborators Sep 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants