【问题标题】:Firebase Email already in use errorFirebase 电子邮件已在使用错误
【发布时间】:2018-04-06 16:59:54
【问题描述】:

我在更新 firebase 后尝试登录我的用户,在跟踪错误后,我收到以下错误:

Error Domain=FIRAuthErrorDomain Code=17007 "电子邮件地址是 已被另一个帐户使用。” UserInfo={NSLocalizedDescription=电子邮件地址已被使用 由另一个帐户。,error_name=ERROR_EMAIL_ALREADY_IN_USE}

看起来似乎是因为该 firebase 用户已经在使用中,我不知道如何解决这个问题。我相信这是因为我在关闭应用程序之前从未退出过用户,但不是无法以我的任何用户身份登录。

下面是我的代码:

@IBAction func Login(sender: AnyObject) {
        let email = self._Email.text!
        let password = self._Password.text!

        Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
            if error == nil {
                //successfull login
                print("Successful login****************************************")

                //performs a segue to the next view controller
                if user!.isEmailVerified{
                    //if the email is verified
                    let vc = self.storyboard!.instantiateViewController(withIdentifier: "ProfileView") as! ProfileView
                    self.present(vc, animated: true, completion: nil)
                }
                else {
                    print("email is not verified")
                }
            } else {
                print("Some login error")
            }
       }
}

【问题讨论】:

  • 您正在使用createUser 登录!此功能旨在用于注册新用户而不是用于登录。而是使用此Auth.auth().signIn(withEmail: email, password: password)

标签: ios swift firebase firebase-authentication


【解决方案1】:

正如 ZassX 所指出的,您确实在使用 Firebase iOS SDK 的 signUp 方法,即 createUserWithEmail。改用此方法使用电子邮件和密码登录:

Auth.auth().signIn(withEmail: email, password: password) { (user, error) in
  // ...
}

更多信息:https://firebase.google.com/docs/auth/ios/password-auth

您可以在 Firebase 身份验证仪表板 (https://console.firebase.google.com) 中查看您的注册用户列表

此外,如果您有错误对象,最好打印出错误描述。像这样:

print(error.localizedDescription).

【讨论】:

  • Ahhh 在更新 firebase 时,由于某种原因,它一定是建议的修复方法......我已经盯着这个看了一段时间
猜你喜欢
  • 2019-06-27
  • 1970-01-01
  • 1970-01-01
  • 2022-07-28
  • 1970-01-01
  • 2017-02-01
  • 1970-01-01
  • 2018-03-16
  • 2018-10-13
相关资源
最近更新 更多