flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 FlutterFire_UI/Auth Email validation fails on '_' (underscore)

Open KelvinConnor opened this issue 4 years ago • 6 comments

Attempt to register an email with an '_' fails: [email protected]

Not sure if this is in the firebase_auth package or _ui package.

flutterfire_ui: ^0.3.0

KelvinConnor avatar Dec 22 '21 20:12 KelvinConnor

this happen when email contain underscore and dash character hope this issue will fixed soon

komangnopha avatar Dec 23 '21 02:12 komangnopha

@KelvinConnor Can you provide flutter doctor -v , pubspec.yaml and a complete minimal code sample that shows this behavior along with any error log / message that you get while trying to register with it ? Thanks.

darshankawar avatar Dec 23 '21 08:12 darshankawar

I don't really have any good code sample since the issue is raised in the UI aspect of the package. No debug info is being provided from the package to help id the exact location of the problem.

I believe this source of the problem is located: https://github.com/FirebaseExtended/flutterfire/blob/eaf0af6c4b0d418aa36d7dd2cd8cd60e40b06ebf/packages/flutterfire_ui/lib/src/auth/validators.dart LN45 final _emailRegexp = RegExp(r'^[a-zA-Z0-9.]+@[a-zA-Z0-9]+.[a-zA-Z]+');

Perhaps just adding the '_' (and perhaps the \-) will fix the issue and the other issue mentioned above.

final _emailRegexp = RegExp(r'^[a-zA-Z0-9_.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z]+');

EmailCapture

Thanks for looking at this!

---------------CODE---------------------------------------------------------------- I am using the code example from 'https://firebase.flutter.dev/docs/ui/auth/integrating-your-first-screen'

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<User?>(
      stream: FirebaseAuth.instance.authStateChanges(),
      builder: (context, snapshot) {
        // User is not signed in
        if (!snapshot.hasData) {
          // ..
          logger.d('User is NOT signed in');
          //return const LoginPage();
          return const SignInScreen(
                  providerConfigs: [
                    EmailProviderConfiguration(),
                  ],
                );
        }
        logger.d('User IS signed in');
        // Render your application if authenticated
        return const HomePage();
      },
    );
  }

---------------FLUTTER DOCTOR -------------------------------------------------------

[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19044.1415], locale en-US) • Flutter version 2.8.1 at C:\dev\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 77d935af4d (7 days ago), 2021-12-16 08:37:33 -0800 • Engine revision 890a5fca2e • Dart version 2.15.1

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\kelvi\AppData\Local\Android\sdk • Platform android-31, build-tools 30.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.1) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.9.31105.61 • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 4.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.62.3) • VS Code at C:\Users\kelvi\AppData\Local\Programs\Microsoft VS Code • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (5 available) • KFFOWI (mobile) • G000H4046223024Q • android-arm • Android 5.1.1 (API 22) • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1415] • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110 • Edge (web) • edge • web-javascript • Microsoft Edge 96.0.1054.43

• No issues found!

----------------------PUBSPEC ----------------------------------------------------------------------

name: flytyersworkbench
description: A new Flutter application.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.15.1 <3.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  firebase_core: ^1.10.6
  flutterfire_ui: ^0.3.0
  logger: ^1.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^1.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg
  assets:
    - assets/images/fly_box_16_9_small.png
    - assets/images/fly_box_16_9_med.png
    - assets/images/fly_box_16_9_large.png
    - assets/images/fly_box_9_16_small.png
    - assets/images/fly_box_9_16_med.png
    - assets/images/fly_box_9_16_large.png
    - assets/images/ftw_logo_300.png

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages


KelvinConnor avatar Dec 23 '21 14:12 KelvinConnor

same

https://github.com/FirebaseExtended/flutterfire/blob/efdcc16aa2f3d45a3835f0eb73801ba88e808e07/packages/flutterfire_ui/lib/src/auth/validators.dart#L45

underscore is just not included in the validator. The validator should be customizable I think. #7638

fieldinrain avatar Dec 27 '21 11:12 fieldinrain

Thanks for the update. Labeling for further investigation and fix.

darshankawar avatar Dec 27 '21 13:12 darshankawar

Actally this does not work with email containing dots tooo. For eg if my mail is [email protected] then UserCrediantial.user.email would return null. Please fix this too. @darshankawar

sulav-crisps avatar Jan 05 '22 17:01 sulav-crisps