Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase_auth] Error code with non-English character #3633

Closed
altay9 opened this issue Sep 23, 2020 · 10 comments
Closed

🐛 [firebase_auth] Error code with non-English character #3633

altay9 opened this issue Sep 23, 2020 · 10 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot Stale Issue with no recent activity

Comments

@altay9
Copy link

altay9 commented Sep 23, 2020

Bug report

Error code with non-English character.
API: firebase_auth: 0.18.0+1.

Example:
The error code "email-already-in-use" looks like this:
emaıl-already-ın-use

Steps to reproduce

Steps to reproduce the behavior:

  1. Use this sample code to register a user in Firebase
try {
       UserCredential result = await _auth.createUserWithEmailAndPassword(
           email: emailCont.text, password: passCont.text);
       user = result.user;
       if (user != null) {
         setState(() {
           userValid = true;
         });
       } else {
         setState(() {
           userValid = false;
         });
       }

     } catch (e) {
       if (e is FirebaseAuthException) {
         if (e.code == 'email-already-in-use') {
           return ToolUtil.getState().showsnack(
               'User with Email Already exists', _scaffoldKeyRegister);
         }
       }
     }
  1. See error or incorrect behavior:
    [firebase_auth/emaıl-already-ın-use] The email address is already in use by another account.

Expected behavior

Error code only in English characters.



Flutter doctor

Click To Expand
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.14393], locale en-US)
    • Flutter version 1.20.4 at C:\Users\ASUS\AppData\Local\Android\flutter
    • Framework revision fba99f6cf9 (9 days ago), 2020-09-14 15:32:52 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at C:\Users\ASUS\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 47.1.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] Connected device (1 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!


Flutter dependencies

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

Click To Expand
Dart SDK 2.9.2
Flutter SDK 1.20.4
infopower 9.0.6+36

dependencies:
- applozic_flutter 0.0.2 [flutter]
- charts_flutter 0.9.0 [charts_common collection flutter intl logging meta]
- cloud_firestore 0.14.0+1 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- cupertino_icons 0.1.3
- firebase_analytics 6.0.0 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_auth 0.18.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_crashlytics 0.1.4+1 [flutter stack_trace]
- firebase_storage 4.0.0 [flutter firebase_core]
- flare_flutter 2.0.6 [flutter flare_dart meta]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_facebook_login 3.0.0 [flutter collection]
- flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math]
- flutter_typeahead 1.8.8 [flutter flutter_keyboard_visibility]
- font_awesome_flutter 8.8.1 [flutter]
- google_sign_in 4.5.1 [google_sign_in_platform_interface flutter meta google_sign_in_web]
- gradient_app_bar 0.1.3 [flutter]
- http 0.12.2 [http_parser path pedantic]
- image_picker 0.6.7+7 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- intl 0.16.1 [path]
- provider 4.3.2 [flutter nested collection]
- settings_ui 0.4.0 [flutter]
- shared_preferences 0.5.10 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web]
- sign_in_with_apple 2.5.2 [meta flutter]
- theme_provider 0.4.0+1 [flutter shared_preferences]
- twitter_login 1.0.1 [flutter crypto http flutter_inappwebview]
- url_launcher 5.6.0 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- yaml 2.2.1 [charcode collection string_scanner source_span]

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:
- async 2.4.2 [collection]
- boolean_selector 2.0.0 [source_span string_scanner]
- characters 1.0.0
- charcode 1.1.3
- charts_common 0.9.0 [collection intl logging meta vector_math]
- clock 1.0.1 [meta]
- cloud_firestore_platform_interface 2.0.1 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.2.0+1 [flutter flutter_web_plugins firebase http_parser meta firebase_core cloud_firestore_platform_interface js]
- collection 1.14.13
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- fake_async 1.1.0 [clock collection]
- file 5.2.1 [intl meta path]
- firebase 7.3.0 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_auth_platform_interface 2.0.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.0+1 [flutter flutter_web_plugins firebase meta http_parser intl firebase_core firebase_auth_platform_interface js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flare_dart 2.3.4
- flutter_inappwebview 4.0.0+4 [flutter uuid mime]
- flutter_keyboard_visibility 3.2.1 [flutter]
- flutter_plugin_android_lifecycle 1.0.9 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- google_sign_in_platform_interface 1.1.2 [flutter meta quiver]
- google_sign_in_web 0.9.1+1 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image_picker_platform_interface 1.1.0 [flutter meta http plugin_platform_interface]
- js 0.6.2
- logging 0.11.4
- matcher 0.12.8 [stack_trace]
- meta 1.1.8
- mime 0.9.7
- nested 0.0.4 [flutter]
- path 1.7.0
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- pedantic 1.9.0
- platform 2.2.1
- platform_detect 1.4.0 [meta pub_semver]
- plugin_platform_interface 1.0.2 [meta]
- process 3.0.13 [file intl meta path platform]
- pub_semver 1.4.4 [collection]
- quiver 2.1.3 [matcher meta]
- shared_preferences_linux 0.0.2+2 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+10 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- sky_engine 0.0.99
- source_span 1.7.0 [charcode collection meta path term_glyph]
- stack_trace 1.9.5 [path]
- stream_channel 2.0.0 [async]
- string_scanner 1.0.5 [charcode meta source_span]
- term_glyph 1.1.0
- test_api 0.2.17 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.2.0 [collection]
- url_launcher_linux 0.0.1+1 [flutter]
- url_launcher_macos 0.0.1+8 [flutter]
- url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.3+2 [url_launcher_platform_interface platform_detect flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+1 [flutter]
- uuid 2.2.2 [crypto convert]
- vector_math 2.0.8
- xdg_directories 0.1.0 [path process flutter]



@altay9 altay9 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 23, 2020
@darshankawar
Copy link

Hi @altayhunoglu,
I am unable to replicate the issue.

I/flutter (25761): User with Email Already exists

I tried below code sample on latest stable (1.20.4)

code sample
void _register() async {
    try {
      UserCredential userCredential = await FirebaseAuth.instance
          .createUserWithEmailAndPassword(
          email: "[email protected]",
          password: "SuperSecretPassword!"
      );
      User user = userCredential.user;
      if (user != null) {
        setState(() {
          userValid = true;
        });
      } else {
        setState(() {
          userValid = false;
        });
      }
    }catch (e) {
      if (e is FirebaseAuthException) {
        if (e.code == 'email-already-in-use') {
          print(
              'User with Email Already exists');
        }
      }
    }
  }
}

Can you try the official plugin example and see if you still get the same behavior ?
Thanks

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 24, 2020
@altay9
Copy link
Author

altay9 commented Sep 24, 2020

Hello @darshankawar,

First of all, may I ask if you know why it is not "ERROR_EMAIL_ALREADY_IN_USE" but "email-already-in-use" instead?

There must be some kind of conversion to lowercase and it causes the problem as my machine was once in Turkish.

In Turkish the lowercase of "I" is "ı"

So, indeed I can simply solve this individual problem like that:

  if (e.code?.toUpperCase() =="EMAIL-ALREADY-IN-USE") {
            return ToolUtil.getState().showsnack(
                AppLocalizations.of(context).translate('email-already-in-use'),
                _scaffoldKeyRegister);
          }

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Sep 24, 2020
@leonardocustodio
Copy link

Actually the correct question should be why there isn't an enum provided by firebase_auth that we can access to compare the error codes? Not very nice to compare with plain string specially when firebase changes those strings -.-

@Ehesp
Copy link
Member

Ehesp commented Sep 26, 2020

@leonardocustodio you'd still have the same problem though right? In order to generate an enum value you need to know the string value, which in this case seems to be a language problem so the enums wouldn't match up anyway.

@altayhunoglu Are you running anything "none standard" here? E.g. an emulator with a different language set etc? Would be interesting to replicate this.

@leonardocustodio
Copy link

leonardocustodio commented Sep 26, 2020

@Ehesp yes, it wouldn't match if firebase changed the string values and the firebase auth package doesn't but as I said in the #3402 in my opinion at least, it's way easier to the package to keep uptodate with firebase string values than each developer alone. Also, when the package is responsible for that there is a lot of developers that can spot that the strings have changed and open an issue to report or make a pull request to fix it. But a developer alone, if he doesn't check often if the values haven't changed who knows how much time it will take for him to know the app isn't working as expected.

I know there is no perfect solution but from where I see this one looks the less painful one. But I could be wrong ;)

@Ehesp
Copy link
Member

Ehesp commented Sep 26, 2020

The native errors (e.g. permission denied) need to be converted to Dart-land code so this will always be required. That discussion is for the other PR anyway.

This is an issue which needs fixing regardless though - hopefully it can be replicated easily.

@altay9
Copy link
Author

altay9 commented Sep 26, 2020

@leonardocustodio you'd still have the same problem though right? In order to generate an enum value you need to know the string value, which in this case seems to be a language problem so the enums wouldn't match up anyway.

@altayhunoglu Are you running anything "none standard" here? E.g. an emulator with a different language set etc? Would be interesting to replicate this.

@Ehesp hello,

You are right. I use emulator in Turkish. I will try after changing the language, as soon as possible.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 28, 2020
@google-oss-bot
Copy link

Hey @altayhunoglu. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot google-oss-bot added the Stale Issue with no recent activity label Oct 6, 2020
@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@altayhunoglu if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@ertan2002
Copy link

we have the same problem..
today I updated the packages and using latest firebase packages..
normally I was getting an error code as "ERROR_INVALID_EMAIL"
but after the update, the error code is "ınvalıd-emaıl"
as you see it is small I (it is i without point). Because in turkish there is i and ı and also İ and I. (one is with point another not).

I could fix this problem by using toUpperCase method but it does not work. Because somehow, it behaves very turkic. That means
when I use upper method, small ı becomes I but it is not same "I" in english because english capital I is coming from "i"
that why when I do something like

"ınvalıd-emaıl".toUpperCase() == "INVALID_EMAIL"

it returns false. So this problem occurred after the update. language of my partner's computer is Turkish and mine is English. and I see the error as expected.

I/flutter (25906): firebase_auth/invalid-email] The email address is badly formatted.
I/flutter (25906): invalid-email

so somehow, the latest version of the package, uses windows's system language for the error codes..

Hope it helps for solving this problem.

@firebase firebase locked and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot Stale Issue with no recent activity
Projects
None yet
Development

No branches or pull requests

6 participants