我在更新 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/