ios - Firebase 电子邮件已在使用错误

标签 ios swift firebase firebase-authentication

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

Error Domain=FIRAuthErrorDomain Code=17007 "The email address is already in use by another account." UserInfo={NSLocalizedDescription=The email address is already in use by another account., 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")
            }
       }
}

最佳答案

正如 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) 中查看您的注册用户列表

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

打印(error.localizedDescription)

关于ios - Firebase 电子邮件已在使用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46935213/

相关文章:

ios - iOS 中的 GCM 到 FCM

objective-c - Xcode 6 没有本地化 Interface Builder

ios - 添加 UIBarButtonItem 覆盖 UINavigationController 后退按钮

swift - 我如何快速初始化具有键范围的字典?

swift 3 和火力地堡 : Retrieve auto id value from snapshot

firebase - Facebook 在 React Native 错误 400 中使用 Firebase 登录

ios - Swift - 奇怪的编码兼容错误

ios - 截取当前前台应用程序的屏幕截图

ios - 使用 NSPredicate 过滤包含具有 NSDate 字段的对象的 NSArray

java - Firestore whereEqualTo、orderBy 和 limit(1) 不起作用