【问题标题】:Firebase not validating emailFirebase 不验证电子邮件
【发布时间】:2019-04-03 21:50:47
【问题描述】:

我目前正在使用 Flutter 创建应用。

目标是在登录之前检查帐户的电子邮件是否经过验证。

现在,用户使用Auth.signInWithEmailAndPassword 登录到他们的帐户

此时,Auth.isEmailVerified 返回 false

之后,会发送一封验证电子邮件,然后用户单击链接以验证他们的帐户,并弹出一个窗口,说明他们的帐户现已通过验证。

用户尝试再次登录,但 Auth.isEmailVerified 仍然返回 false。

有什么想法吗?

这是我正在使用的auth.dart 类文件。

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

这是我的代码。

   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)),
    ),

非常感谢!!

【问题讨论】:

    标签: firebase dart flutter email-verification


    【解决方案1】:

    查看您正在使用的库,需要等待Auth.reload 调用。应该是

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

    由于它不等待重新加载,因此您的代码会继续运行,并在有机会完成重新加载之前检查isEmailVerified

    这个issue 正在报告它,我已经分享了这个信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-23
      • 2018-11-21
      • 2017-05-30
      • 2020-07-16
      • 2021-07-10
      • 2021-10-10
      • 2018-12-25
      相关资源
      最近更新 更多