firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.67k stars 3.97k forks source link

🐛 [AUTH] setPersistence() doesn't work #10238

Closed arisAlexis closed 1 year ago

arisAlexis commented 1 year ago

Bug report

Describe the bug setPersistence does not set persistence using local emulator. Page refresh on web makes FirebaseAuth.instance.currentUser NULL. So does a hot reload.

Steps to reproduce

Steps to reproduce the behavior:

await FirebaseAuth.instance.setPersistence(Persistence.LOCAL); try { UserCredential userCredential = await FirebaseAuth.instance.signInWithEmailAndPassword( email: data.name, password: data.password); return null;

Expected behavior

Persistence should be set at _persistence variable and the next page refresh should have the user authenticated already

Sample project

Providing a minimal example project which demonstrates the bug in isolation from your main App greatly enhances the chance of a timely fix. Please link to the public repository URL.


Additional context

Logs out while debugging


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` C:\Users\arisg>flutter doctor -v [√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22621.963], locale en-US) • Flutter version 3.3.10 on channel stable at C:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 135454af32 (4 weeks ago), 2022-12-15 07:36:55 -0800 • Engine revision 3316dd8728 • Dart version 2.18.6 • DevTools version 2.15.0 [√] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at C:\Users\arisg\AppData\Local\Android\Sdk • Platform android-33, build-tools 32.0.0 • ANDROID_HOME = C:\Users\arisg\AppData\Local\Android\Sdk • Java binary at: C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\211.7628.21.2111.8092744\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Build Tools 2022 17.3.5) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools • Visual Studio Build Tools 2022 version 17.3.32922.545 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2021.1) • Android Studio at C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\211.7628.21.2111.8092744 • Flutter plugin version 63.2.1 • Dart plugin version 203.8452 • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) [√] IntelliJ IDEA Community Edition (version 2022.2) • IntelliJ at C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\222.4459.24 • Flutter plugin version 71.2.5 • Dart plugin version 222.4459.16 [√] IntelliJ IDEA Community Edition (version 2022.3) • IntelliJ at C:\Users\arisg\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\223.8214.52 • Flutter plugin version 71.3.6 • Dart plugin version 223.8214.16 [√] VS Code (version 1.74.1) • VS Code at C:\Users\arisg\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.54.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.963] • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.125 • Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.52 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```

Flutter dependencies

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

Click To Expand ``` dependencies: - cloud_firestore 4.3.1 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_functions 4.0.7 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - cupertino_icons 1.0.5 - firebase_analytics 10.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_app_check 0.1.1+8 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.2.5 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.4.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_storage 11.0.10 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_dotenv 5.0.2 [flutter] - flutter_easyloading 3.0.5 [flutter flutter_spinkit] - flutter_facebook_auth 5.0.7 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web facebook_auth_desktop] - flutter_login 4.1.1 [another_flushbar another_transformer_page_view flutter font_awesome_flutter provider quiver sign_in_button url_launcher] - provider 6.0.5 [collection flutter nested] - rflutter_alert 2.0.4 [flutter] - shared_preferences 2.0.15 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] 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 collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] transitive dependencies: - _flutterfire_internals 1.0.12 [collection firebase_core firebase_core_platform_interface flutter meta] - another_flushbar 1.12.29 [flutter] - another_transformer_page_view 2.0.1 [flutter] - async 2.9.0 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.2.1 - clock 1.1.1 - cloud_firestore_platform_interface 5.10.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.2.1 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions_platform_interface 5.1.26 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.3.15 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.16.0 - facebook_auth_desktop 0.0.8 [flutter http flutter_secure_storage flutter_facebook_auth_platform_interface] - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - file 6.1.4 [meta path] - firebase_analytics_platform_interface 3.3.17 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.1+8 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_app_check_platform_interface 0.0.5+11 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_check_web 0.0.7+11 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.11.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.2.4 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.5.2 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.1.26 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.3.19 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_facebook_auth_platform_interface 4.1.1 [flutter plugin_platform_interface] - flutter_facebook_auth_web 4.1.1 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface] - flutter_secure_storage 7.0.1 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta] - flutter_secure_storage_linux 1.1.2 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 2.0.1 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_platform_interface 1.0.1 [flutter plugin_platform_interface] - flutter_secure_storage_web 1.1.1 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js] - flutter_secure_storage_windows 1.1.3 [flutter flutter_secure_storage_platform_interface] - flutter_spinkit 5.1.0 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - font_awesome_flutter 10.3.0 [flutter] - http 0.13.5 [async http_parser meta path] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - intl 0.17.0 [clock path] - js 0.6.4 - lints 2.0.1 - matcher 0.12.12 [stack_trace] - material_color_utilities 0.1.5 - meta 1.8.0 - nested 1.0.0 [flutter] - path 1.8.2 - path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.5 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.3 [ffi flutter path path_provider_platform_interface win32] - platform 3.1.0 - plugin_platform_interface 2.1.3 [meta] - process 4.2.4 [file path platform] - quiver 3.2.1 [matcher] - shared_preferences_android 2.0.14 [flutter shared_preferences_platform_interface] - shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.1.2 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_macos 2.0.5 [flutter shared_preferences_platform_interface] - shared_preferences_platform_interface 2.1.0 [flutter plugin_platform_interface] - shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.1.2 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - sign_in_button 3.1.0 [flutter font_awesome_flutter] - sky_engine 0.0.99 - source_span 1.9.0 [collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.1 [source_span] - term_glyph 1.2.1 - test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.1 [collection] - url_launcher 6.1.7 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - url_launcher_android 6.0.22 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.1 [flutter plugin_platform_interface] - url_launcher_web 2.0.13 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface] - vector_math 2.1.2 - win32 3.1.3 [ffi] - xdg_directories 0.2.0+2 [meta path process] ```

darshankawar commented 1 year ago

@arisAlexis Thanks for the report. I think this looks similar to https://github.com/firebase/flutterfire/issues/10200, so please follow-up in that issue for further updates. Also please make sure you are using latest flutterfire packages as mentioned here and confirm if this holds true in your case.

Closing this issue as a duplicate. If you disagree, write in comments and I'll reopen it.