firebase / FirebaseUI-Flutter

Apache License 2.0
107 stars 99 forks source link

🐛 Email signing-up (register) not responsive (a case uncovered by current documentation) #351

Open fhfuih opened 5 months ago

fhfuih commented 5 months ago

Is there an existing issue for this?

What plugin is this bug for?

Firebase UI Auth

What platform(s) does this bug affect?

Android, iOS

List of dependencies used.

flutter pub deps -s list
Dart SDK 3.3.0
Flutter SDK 3.19.2
campus 1.0.0+1

dependencies:
- flutter 0.0.0
  - characters 1.3.0
  - collection 1.18.0
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - vector_math 2.1.4
  - sky_engine any
- cupertino_icons 1.0.8
- flutter_localizations 0.0.0
  - flutter any
  - intl 0.18.1
  - characters 1.3.0
  - clock 1.1.1
  - collection 1.18.0
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - path 1.9.0
  - vector_math 2.1.4
- intl 0.18.1
  - clock ^1.1.0
  - meta ^1.0.2
  - path ^1.8.0
- go_router 13.2.5
  - collection ^1.15.0
  - flutter any
  - flutter_web_plugins any
  - logging ^1.0.0
  - meta ^1.7.0
- flutter_dotenv 5.1.0
  - flutter any
- dio 5.4.3+1
  - async ^2.8.2
  - http_parser ^4.0.0
  - meta ^1.5.0
  - path ^1.8.0
- shared_preferences 2.2.3
  - flutter any
  - shared_preferences_android ^2.1.0
  - shared_preferences_foundation ^2.3.5
  - shared_preferences_linux ^2.2.0
  - shared_preferences_platform_interface ^2.3.0
  - shared_preferences_web ^2.1.0
  - shared_preferences_windows ^2.2.0
- cached_network_image 3.3.1
  - cached_network_image_platform_interface ^4.0.0
  - cached_network_image_web ^1.1.1
  - flutter any
  - flutter_cache_manager ^3.3.1
  - octo_image ^2.0.0
- flutter_svg 2.0.10+1
  - flutter any
  - http ^1.0.0
  - vector_graphics ^1.1.11
  - vector_graphics_codec ^1.1.11
  - vector_graphics_compiler ^1.1.11
- provider 6.1.2
  - collection ^1.15.0
  - flutter any
  - nested ^1.0.0
- flutter_map 6.1.0
  - async ^2.9.0
  - collection ^1.17.1
  - flutter any
  - http ^1.0.0
  - latlong2 ^0.9.0
  - logger ^2.0.1
  - meta ^1.9.1
  - polylabel ^1.0.1
  - proj4dart ^2.1.0
  - vector_math ^2.1.2
- latlong2 0.9.1
  - intl >=0.15.0 <1.0.0
- flutter_map_cache 1.5.0
  - flutter any
  - dio_cache_interceptor ^3.4.2
  - dio ^5.2.0+1
  - flutter_map ^6.0.0
- path_provider 2.1.3
  - flutter any
  - path_provider_android ^2.1.0
  - path_provider_foundation ^2.3.2
  - path_provider_linux ^2.2.0
  - path_provider_platform_interface ^2.1.0
  - path_provider_windows ^2.2.0
- dio_cache_interceptor_file_store 1.2.3
  - dio_cache_interceptor ^3.4.4
  - path ^1.8.0
  - synchronized ^3.0.0
- dio_cache_interceptor 3.5.0
  - dio >=5.2.0+1 <6.0.0
  - uuid >=3.0.7 <5.0.0
  - string_scanner ^1.1.0
- url_launcher 6.2.6
  - flutter any
  - url_launcher_android ^6.2.0
  - url_launcher_ios ^6.2.4
  - url_launcher_linux ^3.1.0
  - url_launcher_macos ^3.1.0
  - url_launcher_platform_interface ^2.2.0
  - url_launcher_web ^2.2.0
  - url_launcher_windows ^3.1.0
- flutter_map_animations 0.6.0
  - flutter any
  - flutter_map ^6.1.0
  - latlong2 ^0.9.0
- geolocator 11.1.0
  - flutter any
  - geolocator_platform_interface ^4.1.0
  - geolocator_android ^4.3.0
  - geolocator_apple ^2.3.0
  - geolocator_web ^3.0.0
  - geolocator_windows ^0.2.2
- image_picker 1.1.1
  - flutter any
  - image_picker_android ^0.8.7
  - image_picker_for_web >=2.2.0 <4.0.0
  - image_picker_ios ^0.8.8
  - image_picker_linux ^0.2.1
  - image_picker_macos ^0.2.1
  - image_picker_platform_interface ^2.10.0
  - image_picker_windows ^0.2.1
- firebase_ui_auth 1.14.0
  - email_validator ^2.1.17
  - firebase_auth ^4.17.5
  - firebase_core ^2.25.4
  - firebase_dynamic_links ^5.4.14
  - firebase_ui_localizations ^1.11.0
  - firebase_ui_oauth ^1.5.2
  - firebase_ui_shared ^1.4.1
  - flutter any
  - flutter_localizations any
  - meta ^1.10.0
- firebase_auth 4.19.6
  - firebase_auth_platform_interface ^7.2.7
  - firebase_auth_web ^5.11.6
  - firebase_core ^2.31.1
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - meta ^1.8.0
- firebase_core 2.31.1
  - firebase_core_platform_interface ^5.0.0
  - firebase_core_web ^2.17.0
  - flutter any
  - meta ^1.8.0
- firebase_dynamic_links 5.5.6
  - firebase_core ^2.31.1
  - firebase_core_platform_interface ^5.0.0
  - firebase_dynamic_links_platform_interface ^0.2.6+34
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3

dev dependencies:
- flutter_test 0.0.0
  - flutter any
  - test_api 0.6.1
  - matcher 0.12.16+1
  - path 1.9.0
  - fake_async 1.3.1
  - clock 1.1.1
  - stack_trace 1.11.1
  - vector_math 2.1.4
  - leak_tracker_flutter_testing 2.0.1
  - async 2.11.0
  - boolean_selector 2.1.1
  - characters 1.3.0
  - collection 1.18.0
  - leak_tracker 10.0.0
  - leak_tracker_testing 2.0.1
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - source_span 1.10.0
  - stream_channel 2.1.2
  - string_scanner 1.2.0
  - term_glyph 1.2.1
  - vm_service 13.0.0
- flutter_lints 3.0.2
  - lints ^3.0.0

transitive dependencies:
- _flutterfire_internals 1.3.34
  - collection ^1.0.0
  - firebase_core ^2.31.1
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - meta ^1.8.0
- args 2.5.0
- async 2.11.0
  - collection ^1.15.0
  - meta ^1.1.7
- boolean_selector 2.1.1
  - source_span ^1.8.0
  - string_scanner ^1.1.0
- cached_network_image_platform_interface 4.0.0
  - flutter any
  - flutter_cache_manager ^3.3.1
- cached_network_image_web 1.2.0
  - cached_network_image_platform_interface ^4.0.0
  - flutter any
  - flutter_cache_manager ^3.3.1
- characters 1.3.0
- clock 1.1.1
- collection 1.18.0
- cross_file 0.3.4+1
  - meta ^1.3.0
  - web ^0.5.0
- crypto 3.0.3
  - typed_data ^1.3.0
- desktop_webview_auth 0.0.15
  - crypto ^3.0.3
  - flutter any
  - http ^1.0.0
  - flutter_web_plugins any
  - plugin_platform_interface ^2.1.4
- email_validator 2.1.17
- fake_async 1.3.1
  - clock ^1.1.0
  - collection ^1.15.0
- ffi 2.1.2
- file 7.0.0
  - meta ^1.9.1
  - path ^1.8.3
- file_selector_linux 0.9.2+1
  - cross_file ^0.3.1
  - file_selector_platform_interface ^2.6.0
  - flutter any
- file_selector_macos 0.9.4
  - cross_file ^0.3.1
  - file_selector_platform_interface ^2.6.0
  - flutter any
- file_selector_platform_interface 2.6.2
  - cross_file ^0.3.0
  - flutter any
  - http >=0.13.0 <2.0.0
  - plugin_platform_interface ^2.1.7
- file_selector_windows 0.9.3+1
  - cross_file ^0.3.1
  - file_selector_platform_interface ^2.6.0
  - flutter any
- firebase_auth_platform_interface 7.2.7
  - _flutterfire_internals ^1.3.34
  - collection ^1.16.0
  - firebase_core ^2.31.1
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_auth_web 5.11.6
  - firebase_auth_platform_interface ^7.2.7
  - firebase_core ^2.31.1
  - firebase_core_web ^2.17.0
  - flutter any
  - flutter_web_plugins any
  - http_parser ^4.0.0
  - meta ^1.8.0
  - web ^0.5.1
- firebase_core_platform_interface 5.0.0
  - collection ^1.0.0
  - flutter any
  - flutter_test any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_core_web 2.17.0
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - flutter_web_plugins any
  - meta ^1.8.0
  - web ^0.5.1
- firebase_dynamic_links_platform_interface 0.2.6+34
  - _flutterfire_internals ^1.3.34
  - firebase_core ^2.31.1
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_ui_localizations 1.11.0
  - flutter any
  - flutter_localizations any
  - path ^1.8.3
- firebase_ui_oauth 1.5.2
  - desktop_webview_auth ^0.0.14
  - firebase_auth ^4.17.5
  - firebase_ui_auth ^1.14.0
  - firebase_ui_shared ^1.4.1
  - flutter_svg ^2.0.9
  - flutter any
- firebase_ui_shared 1.4.1
  - flutter any
- fixnum 1.1.0
- flutter_cache_manager 3.3.2
  - clock ^1.1.0
  - collection ^1.18.0
  - file ^7.0.0
  - flutter any
  - http ^1.2.1
  - path ^1.9.0
  - path_provider ^2.1.3
  - rxdart ^0.27.7
  - sqflite ^2.3.3
  - uuid ^4.4.0
- flutter_plugin_android_lifecycle 2.0.19
  - flutter any
- flutter_web_plugins 0.0.0
  - flutter any
  - characters 1.3.0
  - collection 1.18.0
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - vector_math 2.1.4
- geolocator_android 4.6.0
  - flutter any
  - geolocator_platform_interface ^4.1.0
  - meta ^1.10.0
  - uuid >=4.0.0 <6.0.0
- geolocator_apple 2.3.7
  - flutter any
  - geolocator_platform_interface ^4.1.0
- geolocator_platform_interface 4.2.3
  - flutter any
  - plugin_platform_interface ^2.1.6
  - vector_math ^2.1.4
  - meta ^1.9.1
- geolocator_web 3.0.0
  - flutter any
  - flutter_web_plugins any
  - geolocator_platform_interface ^4.1.0
- geolocator_windows 0.2.3
  - flutter any
  - geolocator_platform_interface ^4.1.0
- http 1.2.1
  - async ^2.5.0
  - http_parser ^4.0.0
  - meta ^1.3.0
  - web ^0.5.0
- http_parser 4.0.2
  - collection ^1.15.0
  - source_span ^1.8.0
  - string_scanner ^1.1.0
  - typed_data ^1.3.0
- image_picker_android 0.8.12+1
  - flutter any
  - flutter_plugin_android_lifecycle ^2.0.1
  - image_picker_platform_interface ^2.10.0
- image_picker_for_web 3.0.4
  - flutter any
  - flutter_web_plugins any
  - image_picker_platform_interface ^2.9.0
  - mime ^1.0.4
  - web ^0.5.1
- image_picker_ios 0.8.11+2
  - flutter any
  - image_picker_platform_interface ^2.10.0
- image_picker_linux 0.2.1+1
  - file_selector_linux ^0.9.1+3
  - file_selector_platform_interface ^2.2.0
  - flutter any
  - image_picker_platform_interface ^2.8.0
- image_picker_macos 0.2.1+1
  - file_selector_macos ^0.9.1+1
  - file_selector_platform_interface ^2.3.0
  - flutter any
  - image_picker_platform_interface ^2.8.0
- image_picker_platform_interface 2.10.0
  - cross_file ^0.3.1+1
  - flutter any
  - http >=0.13.0 <2.0.0
  - plugin_platform_interface ^2.1.7
- image_picker_windows 0.2.1+1
  - file_selector_platform_interface ^2.2.0
  - file_selector_windows ^0.9.0
  - flutter any
  - image_picker_platform_interface ^2.8.0
- leak_tracker 10.0.0
  - clock ^1.1.1
  - collection ^1.15.0
  - meta ^1.8.0
  - path ^1.8.3
  - vm_service >=11.10.0 <15.0.0
- leak_tracker_flutter_testing 2.0.1
  - flutter any
  - leak_tracker >=10.0.0 <11.0.0
  - leak_tracker_testing >=2.0.1 <3.0.0
  - matcher ^0.12.16
  - meta ^1.8.0
- leak_tracker_testing 2.0.1
  - leak_tracker >=9.0.0 <11.0.0
  - matcher ^0.12.16
  - meta ^1.11.0
- lints 3.0.0
- lists 1.0.1
  - meta ^1.3.0
- logger 2.3.0
- logging 1.2.0
- matcher 0.12.16+1
  - async ^2.10.0
  - meta ^1.8.0
  - stack_trace ^1.10.0
  - term_glyph ^1.2.0
  - test_api >=0.5.0 <0.8.0
- material_color_utilities 0.8.0
  - collection ^1.15.0
- meta 1.11.0
- mgrs_dart 2.0.0
  - unicode ^0.3.0
- mime 1.0.5
- nested 1.0.0
  - flutter any
- octo_image 2.0.0
  - flutter any
- path 1.9.0
- path_parsing 1.0.1
  - vector_math ^2.1.0
  - meta ^1.3.0
- path_provider_android 2.2.4
  - flutter any
  - path_provider_platform_interface ^2.1.0
- path_provider_foundation 2.4.0
  - flutter any
  - path_provider_platform_interface ^2.1.0
- path_provider_linux 2.2.1
  - ffi >=1.1.2 <3.0.0
  - flutter any
  - path ^1.8.0
  - path_provider_platform_interface ^2.1.0
  - xdg_directories >=0.2.0 <2.0.0
- path_provider_platform_interface 2.1.2
  - flutter any
  - platform ^3.0.0
  - plugin_platform_interface ^2.1.7
- path_provider_windows 2.2.1
  - ffi ^2.0.0
  - flutter any
  - path ^1.8.0
  - path_provider_platform_interface ^2.1.0
  - win32 >=2.1.0 <6.0.0
- petitparser 6.0.2
  - meta ^1.9.0
- platform 3.1.4
- plugin_platform_interface 2.1.8
  - meta ^1.3.0
- polylabel 1.0.1
  - collection ^1.15.0
- proj4dart 2.1.0
  - mgrs_dart ^2.0.0
  - wkt_parser ^2.0.0
  - meta ^1.3.0
- rxdart 0.27.7
- shared_preferences_android 2.2.2
  - flutter any
  - shared_preferences_platform_interface ^2.3.0
- shared_preferences_foundation 2.4.0
  - flutter any
  - shared_preferences_platform_interface ^2.3.0
- shared_preferences_linux 2.3.2
  - file >=6.0.0 <8.0.0
  - flutter any
  - path ^1.8.0
  - path_provider_linux ^2.0.0
  - path_provider_platform_interface ^2.0.0
  - shared_preferences_platform_interface ^2.3.0
- shared_preferences_platform_interface 2.3.2
  - flutter any
  - plugin_platform_interface ^2.1.7
- shared_preferences_web 2.3.0
  - flutter any
  - flutter_web_plugins any
  - shared_preferences_platform_interface ^2.3.0
  - web ^0.5.0
- shared_preferences_windows 2.3.2
  - file >=6.0.0 <8.0.0
  - flutter any
  - path ^1.8.0
  - path_provider_platform_interface ^2.0.0
  - path_provider_windows ^2.0.0
  - shared_preferences_platform_interface ^2.3.0
- sky_engine 0.0.99
- source_span 1.10.0
  - collection ^1.15.0
  - path ^1.8.0
  - term_glyph ^1.2.0
- sprintf 7.0.0
- sqflite 2.3.3+1
  - flutter any
  - sqflite_common >=2.5.0-1 <4.0.0
  - path >=1.8.0 <3.0.0
- sqflite_common 2.5.4
  - synchronized >=3.0.0 <5.0.0
  - path >=1.8.0 <3.0.0
  - meta >=1.3.0 <3.0.0
- stack_trace 1.11.1
  - path ^1.8.0
- stream_channel 2.1.2
  - async ^2.5.0
- string_scanner 1.2.0
  - source_span ^1.8.0
- synchronized 3.1.0+1
- term_glyph 1.2.1
- test_api 0.6.1
  - async ^2.5.0
  - boolean_selector ^2.1.0
  - collection ^1.15.0
  - meta ^1.3.0
  - source_span ^1.8.0
  - stack_trace ^1.10.0
  - stream_channel ^2.1.0
  - string_scanner ^1.1.0
  - term_glyph ^1.2.0
- typed_data 1.3.2
  - collection ^1.15.0
- unicode 0.3.1
  - lists ^1.0.0
- url_launcher_android 6.3.2
  - flutter any
  - url_launcher_platform_interface ^2.3.1
- url_launcher_ios 6.3.0
  - flutter any
  - url_launcher_platform_interface ^2.2.0
- url_launcher_linux 3.1.1
  - flutter any
  - url_launcher_platform_interface ^2.2.0
- url_launcher_macos 3.2.0
  - flutter any
  - url_launcher_platform_interface ^2.2.0
- url_launcher_platform_interface 2.3.2
  - flutter any
  - plugin_platform_interface ^2.1.7
- url_launcher_web 2.3.1
  - flutter any
  - flutter_web_plugins any
  - url_launcher_platform_interface ^2.2.0
  - web ^0.5.0
- url_launcher_windows 3.1.1
  - flutter any
  - url_launcher_platform_interface ^2.2.0
- uuid 4.4.0
  - crypto ^3.0.0
  - sprintf ^7.0.0
  - meta ^1.10.0
  - fixnum ^1.1.0
- vector_graphics 1.1.11+1
  - flutter any
  - http ^1.0.0
  - vector_graphics_codec 1.1.11+1
- vector_graphics_codec 1.1.11+1
- vector_graphics_compiler 1.1.11+1
  - args ^2.3.0
  - meta ^1.7.0
  - path_parsing ^1.0.1
  - xml ^6.3.0
  - vector_graphics_codec 1.1.11+1
  - path ^1.8.0
- vector_math 2.1.4
- vm_service 13.0.0
- web 0.5.1
- win32 5.5.0
  - ffi ^2.1.2
- wkt_parser 2.0.0
- xdg_directories 1.0.4
  - meta ^1.3.0
  - path ^1.8.0
- xml 6.5.0
  - collection ^1.18.0
  - meta ^1.9.0
  - petitparser ^6.0.0

Steps to reproduce

Use the recommended code snippet for the auth signing in page. (I use GoRoute so the code is a bit different, but everything around firebase_ui_auth is the same)

          GoRoute(
            path: '/sign-in',
            builder: (BuildContext context, GoRouterState state) {
              return SignInScreen(
                actions: [
                  AuthStateChangeAction<SignedIn>((context, signInState) {
                    debugPrint("AuthState changed: ${signInState.user!.email}");
                    if (signInState.user!.emailVerified) {
                      context.pushReplacement(HomeScreen.route);
                    } else {
                      context.push('/verify-email');
                    }
                  }),
                ],
              );
            },
          ),

Then in the Sign In page, click "Register", fill in valid credential and click the "Register" button.

Expected Behavior

At least something will happen to indicate that the registration is successful. Either jumping to the email verification page, or the sign in page, or some hint appears.

If nothing happens, the documentation should highlight this intended design, and add post-registration handling in the example code snippet.

Actual Behavior

  1. Nothing happens after successfully adding the user data to the firebase auth database.
  2. The firebase_ui_auth documentation does not clarify this intended(?) behavior, or tell developers how to customize the post-registration behavior.

Additional Information

I post this issue as a "bug" because the documentation says nothing about this phenomenon. So I doubt whether it is really intended that nothing happens after users click the Register button.

Some suggested solutions are:

  1. After I looked deeply into the source code, I found that the AuthState SigningUp is issued before trying to write the user credential in the database, and UserCreated is issued after successfully written the user credential in the database. So below is my solution, and I suggest the example code snippet in the library documentation also change to similar (except for the use of GoRoute)
          GoRoute(
            path: '/sign-in',
            builder: (BuildContext context, GoRouterState state) {
              return SignInScreen(
                actions: [
                  /// SignedIn state happens after a successful signing-in
                  AuthStateChangeAction<SignedIn>((context, signInState) {
                    debugPrint("AuthState changed: ${signInState.user!.email}");
                    if (signInState.user!.emailVerified) {
                      context.pushReplacement(HomeScreen.route);
                    } else {
                      context.push('/verify-email');
                    }
                  }),
                  /// UserCreated state happens after a successful signing-up
                  AuthStateChangeAction<UserCreated>((context, state) {
                    scaffoldMessengerKey.currentState?.showSnackBar(
                      const SnackBar(content: Text("User created. Please sign in now."))
                    );
                    context.push("/verify-email");
                  }),
                ],
              );
            },
          ),
  2. I'd suggest the library developers to (optionally) automatically send an email verification after a successful registration. The option may be provided in the constructor of SignInScreen. Moreover, if app developers decided to not verify emails, there can be another option to automatically sign in after a successful registration.
  3. Although I haven't tried RegisterScreen yet, it sounds like something similar to SignInScreen. I don't know why are there two ways to provide email registration UI, and why we can't customize the "authSwith" (Register/Sign In text button) on the SignInScreen to use dedicated pages instead.