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] Authenticated user isn't being restored after page refresh on flutter web #9219

Closed
dmi3coder opened this issue Jul 25, 2022 · 4 comments
Labels
resolution: duplicate This issue or pull request already exists type: bug Something isn't working

Comments

@dmi3coder
Copy link

dmi3coder commented Jul 25, 2022

Bug report

Describe the bug

Firebase auth isn't being restored on web after page refresh. When I authorise, everything works correctly, and FirebaseAuth.instance.currentUser is also present. However, when I refresh the page, I never receive update that user is authorised, and FirebaseAuth.instance.currentUser is always null.

Steps to reproduce

Steps to reproduce the behavior:

  1. Do authorisation (as in example project)
  2. Observe that FirebaseAuth.instance.currentUser is not null after authorisation
  3. Refresh page (just F5 will work)
  4. Observe the issue

Expected behavior

After refresh, FirebaseAuth.instance.currentUser should be not null after some time, FirebaseAuth.instance.authStateChanges also should send some update after some time that user is authorised

Sample project

https://github.com/dmi3coder/flutter_firebase_web_auth_bug


Additional context

Everything works well on mobile, only web.
I do notice that auth cache is present in local storage. So my assumption is that it's not being restored.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-x64, locale en-DE)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods installed but not working.
        You appear to have CocoaPods installed but it is not working.
        This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
        This can usually be fixed by re-installing CocoaPods.
      To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.4)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 3 categories.

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Flutter SDK 3.0.5
firebase_auth_bug 1.0.0+1

dependencies:
- cupertino_icons 1.0.5
- firebase_analytics 9.2.1 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 3.5.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 1.20.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- google_sign_in 5.4.0 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]

dev dependencies:
- flutter_lints 2.0.1 [lints]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]

transitive dependencies:
- async 2.8.2 [collection meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- characters 1.2.0
- charcode 1.3.1
- clock 1.1.0
- collection 1.16.0
- fake_async 1.3.0 [clock collection]
- firebase_analytics_platform_interface 3.2.1 [firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.4.1+1 [firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- firebase_auth_platform_interface 6.4.0 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 4.1.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_platform_interface 4.5.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 1.7.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- google_sign_in_android 6.0.1 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 5.4.0 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 2.2.0 [flutter quiver]
- google_sign_in_web 0.10.2 [flutter flutter_web_plugins google_sign_in_platform_interface js]
- http_parser 4.0.1 [collection source_span string_scanner typed_data]
- intl 0.17.0 [clock path]
- js 0.6.4
- lints 2.0.0
- matcher 0.12.11 [stack_trace]
- material_color_utilities 0.1.4
- meta 1.7.0
- path 1.8.1
- plugin_platform_interface 2.1.2 [meta]
- quiver 3.1.0 [matcher]
- sky_engine 0.0.99
- source_span 1.8.2 [collection path term_glyph]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- string_scanner 1.1.0 [charcode source_span]
- term_glyph 1.2.0
- test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.1 [collection]
- vector_math 2.1.2

@dmi3coder dmi3coder added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jul 25, 2022
@blopker
Copy link

blopker commented Jul 25, 2022

I can confirm, we are having this issue as well. It's preventing us from upgrading to the newest version of flutterfire.

@dmi3coder
Copy link
Author

@blopker can you tell the version at which it's working for you?

@blopker
Copy link

blopker commented Jul 25, 2022

Sure, we were on firebase_auth_web version 3.3.17, updating to 4.1.1 causes the issue.

Looks like this is already reported though? #9199

@darshankawar darshankawar added the triage Issue is currently being triaged. label Jul 26, 2022
@darshankawar
Copy link

@dmi3coder there's a similar issue open describing your case, #9089, so please follow-up in it for further updates. There's an active PR to fix this issue that you can subscribe to: #9138
Closing this as a duplicate.

@darshankawar darshankawar closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2022
@darshankawar darshankawar added resolution: duplicate This issue or pull request already exists and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jul 26, 2022
@firebase firebase locked and limited conversation to collaborators Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate This issue or pull request already exists type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants