firebase / FirebaseUI-Flutter

Apache License 2.0
101 stars 91 forks source link

πŸ› [firebase_ui_auth] localization not implimented for FirebaseAuthException #45

Closed abdullahmatani closed 11 months ago

abdullahmatani commented 1 year ago

Bug report

Describe the bug Firebase FirebaseAuthException caught during submitting forms (sign-in / forgot password / registeration) do not have localization implimented.

Steps to reproduce

Steps to reproduce the behavior:

  1. Follow steps to install firebase_ui_auth to app.
  2. Add SignInScreen widget to app.
  3. Follow steps for adding firebase_ui_localizations to app.
  4. Run app and fill out test email and password for login / test email for registeration / forgot password forms.
  5. 'Error' should be visible, however, it will not be localized / translated to target language.

Expected behavior

Error should be translated / localized.

Additional context

Photo added to show no localisation of errors returned from submitting forms: image


Flutter doctor

Click To Expand Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22000.1335], locale en-GB) [√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0) [√] Android Studio (version 2021.1) [√] VS Code (version 1.74.2) [√] Connected device (3 available) [√] HTTP Host Availability β€’ No issues found!

Flutter dependencies

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

Click To Expand Dart SDK 2.18.6 Flutter SDK 3.3.10 basic_app 1.0.0+1 dependencies: - 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_dynamic_links 5.0.11 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_ui_auth 1.1.7 [email_validator firebase_auth firebase_core firebase_dynamic_links firebase_ui_localizations firebase_ui_oauth flutter flutter_localizations flutter_svg] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] - flutter_login 4.1.1 [another_flushbar another_transformer_page_view flutter font_awesome_flutter provider quiver sign_in_button url_launcher] - flutter_platform_widgets 2.0.0 [flutter] - font_awesome_flutter 10.3.0 [flutter] - provider 6.0.5 [collection flutter nested] 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 - collection 1.16.0 - crypto 3.0.2 [typed_data] - desktop_webview_auth 0.0.11 [crypto flutter http flutter_web_plugins plugin_platform_interface] - email_validator 2.1.17 - fake_async 1.3.1 [clock collection] - 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_dynamic_links_platform_interface 0.2.3+26 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_ui_localizations 1.0.2 [flutter flutter_localizations intl path] - firebase_ui_oauth 1.1.7 [desktop_webview_auth firebase_auth firebase_ui_auth flutter_svg flutter] - flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - 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_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - petitparser 5.1.0 [meta] - plugin_platform_interface 2.1.3 [meta] - quiver 3.2.1 [matcher] - 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 - xml 6.1.0 [collection meta petitparser]

darshankawar commented 1 year ago

Thanks for the report. Using steps to replicate, seeing same behavior as reported.

brunodmn commented 1 year ago

Same here image

JaviBonilla commented 1 year ago

I think this issue it is still a to-do task as mentioned in the code.

In the meantime, the previous code can be edited to include any other error code not already considered ΒΏfrom over here? Not sure if this is the proper source.

In this case, it is the unknown error code:

String? localizedErrorText(
  String? errorCode,
  FirebaseUILocalizationLabels labels,
) {
  switch (errorCode) {
    case 'user-not-found':
      return labels.userNotFoundErrorText;
    case 'email-already-in-use':
      return labels.emailTakenErrorText;
    case 'too-many-requests':
      return labels.accessDisabledErrorText;
    case 'wrong-password':
      return labels.wrongOrNoPasswordErrorText;
    case 'credential-already-in-use':
      return labels.credentialAlreadyInUseErrorText;
    case 'invalid-verification-code':
      // TODO(@lesnitsky): localization
      return 'The code you entered is invalid. Please try again.';

    // ---------------------------------------------------------------------------------
    // NOTE: this is not reported at https://firebase.google.com/docs/auth/admin/errors,
    // but it's thrown by Firebase Auth when the password is invalid.
    case 'unknown':
      return labels.unknownError;
    // ---------------------------------------------------------------------------------

    default:
      return null;
  }
}
JaviBonilla commented 1 year ago

Ok, so the unknown error code thing is related to this issue firebase/flutterfire#10966, it seems it only happens on web and debug mode.

lesnitsky commented 11 months ago

Since https://github.com/firebase/flutterfire/issues/10966 is closed, I'm closing this issue as well.


For future readers: there's now a way to customize error text.