ios - 如何使用 firebase 在 xcode 中验证电子邮件和密码

标签 ios swift firebase firebase-authentication

我想通过 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/

相关文章:

ios - 从委托(delegate)调用时未输入协议(protocol)方法

ios - Retina 4inch 模拟器放错了我应用程序中的所有内容

ios - UIPrintInteractionController 中的文本不可见

ios - 在 UIView 顶部添加内部阴影

ios - 火力地堡, swift : `runTransactionBlock()` returns null

ios - Firebase SDK 不适用于 iOS 10

android - 图片上传后如何获取图片下载地址

javascript - Firebase 数据库函数无法修改 angularjs 中的 $scope 变量

ios - 删除UITableViewCell并与Plist同步

swift - swift 中这两个枚举声明有什么区别?