【问题标题】:Find whether email and username already exist in Firebase Auth in Flutter App在 Flutter App 中查找电子邮件和用户名是否已存在于 Firebase Auth 中
【发布时间】:2018-12-25 11:44:26
【问题描述】:

我在我的 Flutter 应用程序中使用电子邮件注册并使用 Firebase 身份验证。如何在注册页面上显示输入的电子邮件和用户名是否已存在于数据库中?

【问题讨论】:

    标签: firebase firebase-authentication flutter


    【解决方案1】:

    firebase 会将该信息作为错误消息返回:

    FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password).then((user) {
    
        // do whatever you want to do with new user object
    
      }).catchError((e) {
        print(e.details); // code, message, details
      });
    

    如果电子邮件存在,它将触发catchError。值得注意的是,“详细信息”是人类可读的错误获取器。 'code' 和 'message' 对最终用户毫无用处,但它们是 firebase_auth 上仅有的两个记录。

    【讨论】:

    • 这行得通!如果 displayName 已经存在,我该怎么做?
    • 您必须检查您自己的用户数据库。 displayName 在 firebase 中不是唯一的,只是电子邮件。
    猜你喜欢
    • 2019-01-10
    • 2019-07-15
    • 1970-01-01
    • 2019-12-24
    • 1970-01-01
    • 2019-09-14
    • 2020-04-17
    • 1970-01-01
    相关资源
    最近更新 更多