如何使用 Flutter 在 Firebase 中正确登录和注册?

How to Login and Register CORRECTLY in Firebase with Flutter?

我有这个应用程序可以使用 firebase + 电子邮件验证登录和注册,但如果用户输入用户名、电子邮件、密码......它注册时效率不高,即使电子邮件是错了所以我搜索并找到了一个解决方案,它是 firebase 中的电子邮件验证但问题是如果用户没有验证,Firebase 注册它并且他可以登录(即使电子邮件无效),所以有什么想法吗?也是颤振的新手。 我在注册页面中执行的注册代码:

static Future signup(String email, String password, BuildContext ctx) async {
    String emessage;
    if (email == '' || password == '') {
      emessage = 'Please Provide Valid Email And Password';
    } else {
      emessage = 'An Error Occurred. Please Try Again Later.';
    }
    try {
      final FirebaseUser user = (await _auth.createUserWithEmailAndPassword(
        email: email,
        password: password,
      ))
          .user;
      user.sendEmailVerification();
      return user.uid;
    } catch (e) {
      showDialog(
          context: ctx,
          builder: (BuildContext context) {
            return AlertDialog(
              title: Text('Error'),
              content: Text(emessage),
              actions: [
                FlatButton(
                  onPressed: () => Navigator.pop(context),
                  child: Text('Ok'),
                ),
              ],
            );
          });
    }
  }

createUserWithEmailAndPasswordfirebase docs 未列出任何强制预先电子邮件验证的参数。

你可以

  1. 使用signInWithEmailLink并在首次登录后添加密码。
  2. 禁止没有经过验证的电子邮件地址的用户访问您应用中的内容——就像您对未经身份验证的用户所做的那样。