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

fix(firebase_auth): pass Persistence value to FirebaseAuth.instanceFor(app: app, persistence: persistence) for setting persistence on Web platform #9138

Merged
merged 25 commits into from Jul 27, 2022

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented Jul 18, 2022

Description

"persistence" behaviour has changed on the web platform. This PR fixes "persistence" so it locally persists data as it was before web v9 JS SDK update.

This PR also allows a persistence value to be passed on initialising Auth instance FirebaseAuth.instanceFor(app: app, persistence: persistence).

Related Issues

fixes #9117

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@russellwheatley russellwheatley changed the title fix(firebase_auth): created static method FirebaseAuth.persistenceType() for setting persistence on Web platform fix(firebase_auth)!: created static method FirebaseAuth.persistenceType() for setting persistence on Web platform Jul 19, 2022
@russellwheatley russellwheatley added type: bug Something isn't working plugin: auth platform: web Issues / PRs which are specifically for web. labels Jul 19, 2022
@russellwheatley russellwheatley marked this pull request as ready for review July 19, 2022 15:28
Copy link
Member Author

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of doc updates I'll make.

/// Auth state for applications that are shared by other users or have
/// sensitive data.
///
/// This is only supported on web based platforms.
Future<void> setPersistence(Persistence persistence) async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the Deprecated annotation here so developers will get notified in their IDE?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we need to breaking change this straight away? Is it not possible to deprecate but just call the new method instead, and then eventually we can remove the method in a later release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ehesp this is useless now Firebase.instance.setPersistence() because the value needs to be passed before Firebase.instance is ever called. We could just deprecate it and keep the implementation but it does nothing. We needed a new API (FirebaseAuth.persistenceType()) to pass the value on the very first call of initializeAuth() for web. We felt it made sense to simply remove underlying implementation and throw a deprecation exception so users adopt the new strategy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR description, but just to be clear, setPersistence() is not useless as long as persistence is used to initialize the auth instance here

@sgehrman

This comment was marked as off-topic.

@Salakar
Copy link
Member

Salakar commented Jul 22, 2022

What about having .instanceFor(app: app, persistence: persistence) since its tied directly to making a new auth instance, not sure about a new static api

@russellwheatley russellwheatley changed the title fix(firebase_auth)!: created static method FirebaseAuth.persistenceType() for setting persistence on Web platform fix(firebase_auth)!: pass Persistence value to FirebaseAuth.instanceFor(app: app, persistence: persistence) for setting persistence on Web platform Jul 22, 2022
…terfire into @russell/auth-9117

� Conflicts:
�	docs/auth/start.md
�	packages/firebase_auth/firebase_auth/lib/src/firebase_auth.dart
@russellwheatley russellwheatley changed the title fix(firebase_auth)!: pass Persistence value to FirebaseAuth.instanceFor(app: app, persistence: persistence) for setting persistence on Web platform feat(firebase_auth): pass Persistence value to FirebaseAuth.instanceFor(app: app, persistence: persistence) for setting persistence on Web platform Jul 25, 2022
@russellwheatley russellwheatley added type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API. and removed type: bug Something isn't working labels Jul 25, 2022
Copy link
Member Author

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update this doc change after code review.

docs/auth/start.md Outdated Show resolved Hide resolved
@russellwheatley russellwheatley changed the title feat(firebase_auth): pass Persistence value to FirebaseAuth.instanceFor(app: app, persistence: persistence) for setting persistence on Web platform fix(firebase_auth): pass Persistence value to FirebaseAuth.instanceFor(app: app, persistence: persistence) for setting persistence on Web platform Jul 25, 2022
docs/auth/start.md Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: web Issues / PRs which are specifically for web. plugin: auth type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flutter Web Firebase Auth User Logged Out On Page Refresh
5 participants