aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.32k stars 247 forks source link

Auth > "There is already a user which is signed in" on iOS #1876

Closed dmytrohurskyi closed 2 years ago

dmytrohurskyi commented 2 years ago

Description

There is a strange issue with sign in behaviour on iOS devices. I get this auth exception InvalidStateException with a message "There is already a user which is signed in. Please log out the user before calling showSignIn" every time I try to sign in a user on a few particular iOS devices. I have tested it on several iPhones, but it happens only on two of them. Both have iOS 15.5 installed. I've investigated the other open/closed GitHub issues on this exception and tried to add SignOut before every login. It does not help in this case. Issue appears even after reinstalling an application.

Categories

Steps to Reproduce

Actually, I can't reproduce it on my other devices. But these are the steps that I have made when it first appeared:

  1. Start Flutter app (release build)
  2. Sign in a user
  3. Stop the app
  4. Install a newer build of this app and start it
  5. Attempt to Sign in and see an exception

    There is already a user which is signed in. Please log out the user before calling showSignIn

Screenshots

No response

Platforms

Android Device/Emulator API Level

No response

Environment

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

Dependencies

dependencies:
- amplify_auth_cognito 0.6.1 [amplify_auth_cognito_android amplify_auth_cognito_ios amplify_core aws_common collection flutter meta plugin_platform_interface]
- amplify_flutter 0.6.1 [amplify_core amplify_datastore_plugin_interface amplify_flutter_android amplify_flutter_ios aws_common collection flutter meta plugin_platform_interface]
- built_collection 5.1.1
- built_value 8.3.3 [built_collection collection fixnum meta]
- cached_network_image 3.2.1 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- camera 0.9.8+1 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle quiver]
- connectivity_plus 2.3.5 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows]
- cupertino_icons 1.0.5
- device_info_plus 4.0.0 [flutter device_info_plus_platform_interface device_info_plus_macos device_info_plus_linux device_info_plus_web device_info_plus_windows]
- devicelocale 0.5.2 [flutter flutter_web_plugins]
- dio 4.0.6 [http_parser path]
- dio_cache_interceptor 3.2.7 [dio uuid string_scanner]
- dio_cache_interceptor_hive_store 3.1.1 [dio_cache_interceptor hive]
- ffmpeg_kit_flutter_https_gpl 4.5.1 [ffmpeg_kit_flutter_platform_interface flutter]
- file_picker 4.6.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32]
- firebase_analytics 9.1.12 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_core 1.19.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 2.8.4 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_dynamic_links 4.3.1 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface]
- firebase_messaging 11.4.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_remote_config 2.0.11 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_custom_tabs 1.0.4 [flutter flutter_custom_tabs_platform_interface flutter_custom_tabs_web meta]
- flutter_dotenv 5.0.2 [flutter]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_native_splash 2.2.4 [args flutter flutter_web_plugins image js lint meta path universal_io xml yaml]
- flutter_redux 0.10.0 [redux flutter]
- flutter_secure_storage 5.0.2 [meta flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows]
- flutter_svg 1.1.1+1 [flutter meta path_drawing vector_math xml]
- get_it 7.2.0 [async collection]
- google_fonts 3.0.1 [flutter http path_provider crypto]
- image_cropper 2.0.3 [flutter image_cropper_platform_interface image_cropper_for_web]
- intl 0.17.0 [clock path]
- just_audio 0.9.27 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid crypto meta flutter]
- notification_permissions 0.6.1 [flutter]
- package_info_plus 1.4.2 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web]
- path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows]
- permission_handler 9.2.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface]
- platform_device_id 1.0.1 [flutter platform_device_id_platform_interface platform_device_id_macos platform_device_id_linux platform_device_id_web platform_device_id_windows device_info]
- rive 0.9.0 [collection flutter graphs http meta]
- share_plus 4.0.10 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web]
- url_launcher 6.1.4 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- video_player 2.4.5 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]
- video_thumbnail 0.5.0 [flutter]
- visibility_detector 0.3.3 [flutter]
- wiredash 0.7.1 [file flutter http http_parser path_provider shared_preferences]

transitive dependencies:
- amplify_auth_cognito_android 0.6.1 [flutter]
- amplify_auth_cognito_ios 0.6.1 [amplify_core flutter]
- amplify_core 0.6.1 [aws_common collection flutter intl json_annotation meta plugin_platform_interface uuid]
- amplify_datastore_plugin_interface 0.6.1 [amplify_core collection flutter meta]
- amplify_flutter_android 0.6.1 [flutter]
- amplify_flutter_ios 0.6.1 [amplify_core flutter]
- archive 3.3.0 [crypto path]
- args 2.3.1
- async 2.8.2 [collection meta]
- audio_session 0.1.8 [flutter flutter_web_plugins rxdart meta]
- aws_common 0.1.1 [async collection http meta stream_transform uuid]
- boolean_selector 2.1.0 [source_span string_scanner]
- cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.0.1 [flutter flutter_cache_manager cached_network_image_platform_interface]
- camera_android 0.9.8+3 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform]
- camera_avfoundation 0.9.8+2 [camera_platform_interface flutter stream_transform]
- camera_platform_interface 2.2.0 [cross_file flutter plugin_platform_interface stream_transform]
- camera_web 0.2.1+6 [camera_platform_interface flutter flutter_web_plugins stream_transform]
- characters 1.2.0
- charcode 1.3.1
- clock 1.1.0
- collection 1.16.0
- connectivity_plus_linux 1.3.1 [flutter connectivity_plus_platform_interface meta nm]
- connectivity_plus_macos 1.2.4 [connectivity_plus_platform_interface flutter]
- connectivity_plus_platform_interface 1.2.1 [flutter meta plugin_platform_interface]
- connectivity_plus_web 1.2.2 [connectivity_plus_platform_interface flutter_web_plugins flutter]
- connectivity_plus_windows 1.2.2 [connectivity_plus_platform_interface flutter]
- cross_file 0.3.3+1 [js meta]
- crypto 3.0.2 [typed_data]
- csslib 0.17.2 [source_span]
- dbus 0.7.4 [args ffi meta xml]
- device_info 2.0.3 [flutter device_info_platform_interface]
- device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- device_info_plus_linux 2.1.1 [device_info_plus_platform_interface file flutter meta]
- device_info_plus_macos 2.2.3 [device_info_plus_platform_interface flutter]
- device_info_plus_platform_interface 2.3.0+1 [flutter meta plugin_platform_interface]
- device_info_plus_web 2.1.0 [device_info_plus_platform_interface flutter_web_plugins flutter]
- device_info_plus_windows 2.1.1 [device_info_plus_platform_interface ffi flutter win32]
- fake_async 1.3.0 [clock collection]
- ffi 1.2.1
- ffmpeg_kit_flutter_platform_interface 0.2.1 [flutter plugin_platform_interface]
- file 6.1.2 [meta path]
- firebase_analytics_platform_interface 3.1.10 [firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.4.0+17 [firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- firebase_core_platform_interface 4.4.3 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 1.6.6 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_crashlytics_platform_interface 3.2.10 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_dynamic_links_platform_interface 0.2.3+6 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 3.5.4 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 2.4.4 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- firebase_remote_config_platform_interface 1.1.10 [firebase_core flutter meta plugin_platform_interface]
- firebase_remote_config_web 1.0.16 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js]
- fixnum 1.0.1
- flutter_blurhash 0.7.0 [flutter]
- flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid]
- flutter_custom_tabs_platform_interface 1.0.1 [flutter plugin_platform_interface meta]
- flutter_custom_tabs_web 1.0.0 [flutter flutter_web_plugins flutter_custom_tabs_platform_interface meta url_launcher_web url_launcher_platform_interface]
- flutter_plugin_android_lifecycle 2.0.6 [flutter]
- flutter_secure_storage_linux 1.1.0 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_macos 1.1.0 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_platform_interface 1.0.0 [flutter plugin_platform_interface]
- flutter_secure_storage_web 1.0.2 [flutter flutter_web_plugins flutter_secure_storage_platform_interface js]
- flutter_secure_storage_windows 1.1.2 [flutter flutter_secure_storage_platform_interface]
- 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]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- graphs 2.1.0 [collection]
- hive 2.2.3 [meta crypto]
- html 0.15.0 [csslib source_span]
- http 0.13.4 [async http_parser meta path]
- http_parser 4.0.1 [collection source_span string_scanner typed_data]
- image 3.2.0 [archive meta xml]
- image_cropper_for_web 0.0.4 [flutter flutter_web_plugins image_cropper_platform_interface js]
- image_cropper_platform_interface 2.0.0 [flutter plugin_platform_interface http]
- js 0.6.4
- json_annotation 4.5.0 [meta]
- just_audio_platform_interface 4.2.0 [flutter plugin_platform_interface]
- just_audio_web 0.4.7 [just_audio_platform_interface flutter flutter_web_plugins]
- lint 1.8.2
- matcher 0.12.11 [stack_trace]
- material_color_utilities 0.1.4
- meta 1.7.0
- mime 1.0.2
- nm 0.5.0 [dbus]
- octo_image 1.0.2 [flutter flutter_blurhash]
- package_info_plus_linux 1.0.5 [package_info_plus_platform_interface flutter path]
- package_info_plus_macos 1.3.0 [flutter]
- package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface]
- package_info_plus_web 1.0.5 [flutter flutter_web_plugins http meta package_info_plus_platform_interface]
- package_info_plus_windows 1.0.5 [package_info_plus_platform_interface ffi flutter win32]
- path 1.8.1
- path_drawing 1.0.0 [vector_math meta path_parsing flutter]
- path_parsing 1.0.0 [vector_math meta]
- path_provider_android 2.0.16 [flutter path_provider_platform_interface]
- path_provider_ios 2.0.10 [flutter path_provider_platform_interface]
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_macos 2.0.6 [flutter path_provider_platform_interface]
- path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface]
- path_provider_windows 2.0.7 [ffi flutter path path_provider_platform_interface win32]
- pedantic 1.11.1
- permission_handler_android 9.0.2+1 [flutter permission_handler_platform_interface]
- permission_handler_apple 9.0.4 [flutter permission_handler_platform_interface]
- permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface]
- permission_handler_windows 0.1.0 [flutter permission_handler_platform_interface]
- petitparser 5.0.0 [meta]
- platform 3.1.0
- platform_device_id_linux 1.0.0 [flutter]
- platform_device_id_macos 1.0.0 [flutter]
- platform_device_id_platform_interface 1.0.0 [flutter plugin_platform_interface]
- platform_device_id_web 1.0.0 [flutter flutter_web_plugins platform_device_id_platform_interface]
- platform_device_id_windows 1.0.0 [flutter]
- plugin_platform_interface 2.1.2 [meta]
- process 4.2.4 [file path platform]
- quiver 3.1.0 [matcher]
- redux 5.0.0
- rxdart 0.27.4
- share_plus_linux 3.0.0 [share_plus_platform_interface file flutter meta url_launcher]
- share_plus_macos 3.0.1 [share_plus_platform_interface flutter]
- share_plus_platform_interface 3.0.3 [flutter meta mime plugin_platform_interface]
- share_plus_web 3.0.1 [share_plus_platform_interface url_launcher flutter flutter_web_plugins meta]
- share_plus_windows 3.0.1 [share_plus_platform_interface flutter meta url_launcher]
- 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]
- shared_preferences_android 2.0.12 [flutter shared_preferences_platform_interface]
- shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.1.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_macos 2.0.4 [flutter shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface]
- shared_preferences_windows 2.1.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.99
- source_span 1.8.2 [collection path term_glyph]
- sqflite 2.0.2+1 [flutter sqflite_common path]
- sqflite_common 2.2.1+1 [synchronized path meta]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- stream_transform 2.0.0
- string_scanner 1.1.0 [charcode source_span]
- synchronized 3.0.0+2
- 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]
- universal_io 2.0.4 [collection crypto meta typed_data]
- url_launcher_android 6.0.17 [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.0 [flutter plugin_platform_interface]
- url_launcher_web 2.0.12 [flutter flutter_web_plugins url_launcher_platform_interface]
- url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface]
- uuid 3.0.6 [crypto]
- vector_math 2.1.2
- video_player_android 2.3.6 [flutter video_player_platform_interface]
- video_player_avfoundation 2.3.5 [flutter video_player_platform_interface]
- video_player_platform_interface 5.1.3 [flutter plugin_platform_interface]
- video_player_web 2.0.10 [flutter flutter_web_plugins video_player_platform_interface]
- win32 2.6.1 [ffi]
- xdg_directories 0.2.0+1 [meta path process]
- xml 6.1.0 [collection meta petitparser]
- yaml 3.1.1 [collection source_span string_scanner]

Device

iPhone 11 Pro Max, iPhone SE (1st generation)

OS

iOS 15.5

CLI Version

9.1.0

Additional Context

No response

HuiSF commented 2 years ago

Did you install the App onto these problematic devices previously, and signed in a user, and then deleted App without signing out?

haverchuck commented 2 years ago

@dmytrohurskyi Sorry you've been experiencing this issue. I've been trying to reproduce it on my own device (iPhone 12, iOS 14.8.1) and have not. I'm now upgrading to 15.5 to retry. Just to help make sure I'm completing the repro steps correctly, please clarify one thing: When you say "Install a newer build of this app and start it", do you mean simply re-running flutter run --release again, or are you distributing an .ipa to the device?

dmytrohurskyi commented 2 years ago

Did you install the App onto these problematic devices previously, and signed in a user, and then deleted App without signing out?

@HuiSF Yeah, exactly

Jordan-Nelson commented 2 years ago

@dmytrohurskyi - Have you installed the same app on these devices with multiple amplify/Cognito configurations?

dmytrohurskyi commented 2 years ago

@dmytrohurskyi Sorry you've been experiencing this issue. I've been trying to reproduce it on my own device (iPhone 12, iOS 14.8.1) and have not. I'm now upgrading to 15.5 to retry. Just to help make sure I'm completing the repro steps correctly, please clarify one thing: When you say "Install a newer build of this app and start it", do you mean simply re-running flutter run --release again, or are you distributing an .ipa to the device?

@haverchuck re-running with "flutter run --release" should be enough

haverchuck commented 2 years ago

@dmytrohurskyi Ok thanks - I am still unable to reproduce this issue. I will keep trying though.

haverchuck commented 2 years ago

@dmytrohurskyi a) Are you using Hosted UI along with the regular Auth APIs? If you are using Hosted UI, how did the affected users signIn? b) Are you seeing any exceptions on a signOut (you can try running the application via XCode for additional logs). c) Can you share a code snippet of how/where you are calling signOut?

durannumit commented 2 years ago

I'm facing the same exact issue

Also Amplify.Auth.getCurrentUser() does not return a valid user but it throws There is already a user which is signed in. How I can still signOut the user?

I'm trying to call signOut() before every signIn() to avoid conflicts. But that's not the optimal way

sopanawit commented 4 months ago

@durannumit Did you solve this issue? I tried to call signOut() before every signIn() but I sometimes got the failed to sign out but when called signIn() I got There is already a user which is signed in. Please log out the user before calling showSignIn

Jordan-Nelson commented 4 months ago

If you are still facing this issue can you please open a new issue and fill out the issue in the issue template? Thanks.