Firebase not validating email

480

Looking at the library that you are using the Auth.reload call needs to be awaited. It should be

    static Future<bool> reload() async {
      await _user?.reload();
      return _setUserFromFireBase(_user);
    }

Since it is not awaiting on reload, the your code simply keeps on going and it checks isEmailVerified before it has a chance to complete the reload.

This issue is reporting it which I have shared this info.

Share:
480
flutterHelpz
Author by

flutterHelpz

Updated on December 07, 2022

Comments

  • flutterHelpz
    flutterHelpz over 1 year

    I'm currently creating an app using Flutter.

    The goal is to check to see if an account's email is verified before logging them in.

    As it is now, a user signs in to their account using Auth.signInWithEmailAndPassword

    At this point, Auth.isEmailVerified returns false

    Afterwards, a verification email is sent, the user then clicks on the link to verify their account and a window popup appears stating that their account is now verified.

    The user tries to login again, but Auth.isEmailVerified still returns false.

    Any ideas?

    This is the auth.dart class file I'm using.

    https://github.com/AndriousSolutions/auth/blob/master/lib/auth.dart

    And this is my code.

       child: MaterialButton(
          minWidth: 200.0,
          height: 42.0,
          onPressed: () async {
            if (_formKey.currentState.validate()) {
              Auth.signInWithEmailAndPassword(
                      email: emailAddressController.text,
                      password: passwordController.text)
                  .then((onSuccess) {
                Auth.reload();
                if ((onSuccess)) {
                  if (Auth.isEmailVerified) {
                    db.createUser(
                        emailAddress: Auth.email,
                        firstName: Tools.getFirstName(Auth.displayName),
                        googleAccount: false);
                    Navigator.of(context).pushReplacementNamed(HomePage.tag);
                  } else {
                    emailVerificationDialog(context);
                    Auth.sendEmailVerification();
                  }
                }
              }).catchError((e) {
                print(" LSAHJDSAKHDSA " + e);
              });
            }
          },
          color: ThemeSettings.RaisedButtonColor,
          child: Text('Log In', style: TextStyle(color: Colors.white)),
        ),
    

    Thank you so so much!!