gpt4 book ai didi

swift - 密码恢复/重置

转载 作者:行者123 更新时间:2023-11-28 08:40:54 25 4
gpt4 key购买 nike

我无法理解 Firebase 的文档。在我的登录 ViewController 中,我有一个允许用户重置密码的按钮。因此,当用户按下按钮时,它会打开一个警报 Controller ,用户必须在其中输入他们的电子邮件才能收到密码重置/恢复。

@IBAction func forgottenPassword(sender: AnyObject) {

var loginTextField: UITextField?
let alertController = UIAlertController(title: "Password Recovery", message: "Please enter your email address", preferredStyle: .Alert)
let ok = UIAlertAction(title: "OK", style: .Default, handler: { (action) -> Void in

if loginTextField?.text != "" {
DataService.dataService.BASE_REF.resetPasswordForUser(loginTextField?.text, withCompletionBlock: { (error) in
if (error == nil) {

self.showErrorAlert("Password reset", msg: "Check your inbox to reset your password")

} else {
print(error)
self.showErrorAlert("Unidentified email address", msg: "Please re-enter the email you registered with")
}
})
}
print("textfield is empty")

})
let cancel = UIAlertAction(title: "Cancel", style: .Cancel) { (action) -> Void in

}
alertController.addAction(ok)
alertController.addAction(cancel)
alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
// Enter the textfiled customization code here.
loginTextField = textField
loginTextField?.placeholder = "Enter your login ID"
}
presentViewController(alertController, animated: true, completion: nil)

}


func showErrorAlert(title: String, msg: String) {
let alert = UIAlertController(title: title, message: msg, preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default, handler: nil)
alert.addAction(action)
presentViewController(alert, animated: true, completion: nil)
}

Firebase 后端服务器是否会自动生成代码以向用户发送重置电子邮件?

我需要提供更多代码吗?比如sendPasswordResetForEmail()? ... 还是 Firebase 后端服务从这里处理它? ...

最佳答案

这就是您正在寻找的功能吗?

resetPasswordForUser(email:withCompletionBlock:)

只需在您的 Firebase 实例上调用它。然后转到您的应用仪表板以自定义将在密码更改时发送给用户的电子邮件。

enter image description here

关于swift - 密码恢复/重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36503603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com