我想通过 Firebase 中的验证电子邮件来验证使用电子邮件和密码登录的用户。
这是我的代码:
@IBAction func Login(_ sender: Any) {
guard let email = txtUser.text, email != "",
let password = txtPass.text, password != ""
else {
AlertController.showAlert(self, title: "Missing Info", message: "Please fill out all required fields")
return
}
Auth.auth().signIn(withEmail: txtUser.text!, password: txtPass.text!, completion: { (authResult,error) in
if error != nil{
AlertController.showAlert(self, title: "Error", message: error!.localizedDescription)
} else if authResult != nil {
self.performSegue(withIdentifier: "SegueMode", sender: self)
}
})
}
最佳答案
你试过这个吗
Auth.auth().sendSignInLink(toEmail:email,
actionCodeSettings: actionCodeSettings) { error in
// ...
if let error = error {
self.showMessagePrompt(error.localizedDescription)
return
}
// The link was successfully sent. Inform the user.
// Save the email locally so you don't need to ask the user for it again
// if they open the link on the same device.
UserDefaults.standard.set(email, forKey: "Email")
self.showMessagePrompt("Check your email for link")
// ...
}
关于ios - 如何使用 firebase 在 xcode 中验证电子邮件和密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58519092/