Closed talhakosen closed 3 years ago
Hi @talhakosen
What device and android version is this on?
Not seeing this when just performing adb install
on firebase_auth: ^1.1.2
.
Thank you
Hi Markus, it is really interesting but it happens only when install the app through google play. Thats why i could not understand till publish the app. While was working on 1.0.3 i havent faced that kind of issue. Xiaomi - Android 10 Samsung Galaxy SM-A320FL - Android 8.0.0
Oddly enought I'm having the exact opposite problem, where it's always null. #5964
Can't reproduce this through google play either. Tried on both Samsung and Xiaomi Android 10. Does it happen with some specific auth method? Could you try clearing the app cache on the device to see what users cause this?
I can reproduce it every time. On Firebase there is one user which returns for all new install, so when someone install the app start seeing this user's profile... if i disable it on Firebase everything goes normal.
And it is weird how Flutter API can reach this user's information before login, since i just call FirebaseAuth.instance.currentUser
on very first run of the application.
Meantime, i also reached out Firebase team and they are investigating, too.
Labeling this based on the report for now, hopefully the firebase team will have some answers
FirebaseAuth.instance.currentUser
is null when i hot restart the app, is it a bug?
Issue found , i was using FirebaseAuth.instance.userChanges()
in my AuthenticationBloc
and i assume because of threading issue it was returning UID as null. WIth this null uid , i was querying firebase with a where query and it was returning a random user from db.
Now i moved listener in to 'initState' and call emit user data through my bloc. And it works.
void initState() {
FirebaseAuth.instance.userChanges().listen((user) {
getIt<AuthenticationBloc>().add(AuthAppStartedEvent(user));
});
super.initState();
}
Thank you @markusaksli-nc for your time and support.
Bug report
Describe the bug Very first installation of the android application,
FirebaseAuth.instance.currentUser
is not null and returns a random user from Firebase. It looks Firebase caching a user and returns.A workaround solution.
i created a flag
isLoggedInOnDevice
and make this valuetrue
if user logged in before on the device.But this time, all the user who installed the app and logged in before, logged out and had to relogin.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
When the app is installed to a device, FirebaseAuth.instance.currentUser should be null
Additional context
Add any other context about the problem here.
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, 2.0.5, on macOS 11.2.3 20D91 darwin-arm, locale en-NL) [โ] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [โ] Xcode - develop for iOS and macOS [โ] Chrome - develop for the web [โ] Android Studio [โ] Android Studio (version 4.1) [โ] VS Code (version 1.55.2) [โ] Connected device (2 available) โข No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Dart SDK 2.12.3 Flutter SDK 2.0.5 styloor 1.8.6+49 dependencies: - cached_network_image 3.0.0 [flutter flutter_cache_manager octo_image] - cloud_firestore 1.0.6 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta] - cloud_firestore_web 1.0.6 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions 1.0.4 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - equatable 2.0.0 [collection meta] - file_picker 3.0.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface] - firebase_analytics 7.1.1 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta] - firebase_auth 1.1.2 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_auth_web 1.1.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core 1.1.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.0.1 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_dynamic_links 0.8.0 [flutter firebase_core] - firebase_messaging 9.1.0 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 8.0.1 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_bloc 7.0.0 [flutter bloc provider] - flutter_credit_card 2.0.0 [flutter] - flutter_linkify 5.0.0 [flutter linkify] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - flutter_pdfview 1.1.0 [flutter] - flutter_rating_bar 4.0.0 [flutter] - flutter_svg 0.21.0-nullsafety.0 [flutter meta path_drawing vector_math xml] - font_awesome_flutter 9.0.0 [flutter] - get_it 6.0.0 [async collection] - google_fonts 2.0.0 [flutter http path_provider crypto] - image 3.0.2 [archive meta xml] - intl 0.17.0 [clock path] - lint 1.5.3 - loading_indicator 2.0.1 [flutter async] - logger 1.0.0 - lottie 1.0.1 [archive characters charcode collection flutter logging meta path vector_math] - package_info 2.0.0 [flutter] - permission_handler 6.1.1 [flutter meta permission_handler_platform_interface] - rxdart 0.26.0 - share 2.0.1 [meta mime flutter] - shared_preferences 2.0.5 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - shimmer 2.0.0-nullsafety.0 [flutter] - timeago 3.0.2 - url_launcher 6.0.3 [flutter url_launcher_platform_interface url_launcher_linux url_launcher_macos url_launcher_windows url_launcher_web] - webview_flutter 2.0.4 [flutter] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - archive 3.1.2 [crypto path] - async 2.5.0 [collection] - bloc 7.0.0 [meta] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.1.0 - charcode 1.2.0 - clock 1.1.0 - cloud_firestore_platform_interface 4.0.2 [collection firebase_core flutter meta plugin_platform_interface] - cloud_functions_platform_interface 5.0.2 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.0.4 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.15.0 - crypto 3.0.0 [collection typed_data] - fake_async 1.2.0 [clock collection] - ffi 1.0.0 - file 6.1.0 [meta path] - firebase 9.0.1 [http http_parser js] - firebase_analytics_platform_interface 1.1.0 [flutter meta] - firebase_analytics_web 0.2.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta] - firebase_auth_platform_interface 4.2.0 [firebase_core flutter meta plugin_platform_interface] - firebase_core_platform_interface 4.0.0 [flutter meta plugin_platform_interface] - firebase_core_web 1.0.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.0.1 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 2.1.0 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 1.0.3 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 2.0.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 1.0.2 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.0.1 [clock collection file flutter http image path path_provider pedantic rxdart sqflite uuid] - flutter_plugin_android_lifecycle 2.0.0 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - http 0.13.1 [http_parser meta path pedantic] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - js 0.6.3 - linkify 4.0.0 - logging 1.0.1 - matcher 0.12.10 [stack_trace] - meta 1.3.0 - mime 1.0.0 - nested 1.0.0 [flutter] - octo_image 1.0.0 [flutter flutter_blurhash] - path 1.8.0 - path_drawing 0.5.0-nullsafety.0 [vector_math meta path_parsing flutter] - path_parsing 0.2.0-nullsafety.0 [vector_math meta] - path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.0 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.0 - permission_handler_platform_interface 3.1.1 [flutter meta plugin_platform_interface] - petitparser 4.0.2 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.2.1 [file path platform] - provider 5.0.0 [collection flutter nested] - shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows] - sky_engine 0.0.99 - source_span 1.8.0 [charcode collection path term_glyph] - sqflite 2.0.0+3 [flutter sqflite_common path] - sqflite_common 2.0.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.0 [collection] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.0 [url_launcher_platform_interface meta flutter flutter_web_plugins] - url_launcher_windows 2.0.0 [flutter] - uuid 3.0.3 [crypto] - vector_math 2.1.0 - win32 2.0.5 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.0.2 [collection meta petitparser] ```