如何使用firebase

时间:2018-04-29 18:55:09

标签: swift firebase firebase-authentication

我曾尝试使用firebase重新验证用户,但我似乎无法让它工作。我查看了firebase文档,但它没有帮助我。这就是我得到的。

var emailTextField: UITextField!
var currentPasswordTextfield: UITextField!

let reEnterInfo = UIAlertController(title: "Re-Enter Email and Password", message: nil, preferredStyle: .alert)
        reEnterInfo.addTextField(configurationHandler: emailTextField)
        reEnterInfo.addTextField(configurationHandler: currentPasswordTextfield)
        let reSignInButton = UIAlertAction(title: "Re-Sign In", style: .default, handler: self.reSignIn)
        reEnterInfo.addAction(reSignInButton)
        self.present(reEnterInfo, animated: true, completion: nil)

  func reSignIn(alert: UIAlertAction!)
  {
    let user = Auth.auth().currentUser
    let credential: AuthCredential

    user?.reauthenticate(with: credential) { error in
        if error != nil {

        } else {

        }
   }
}

我正在尝试重新验证以更改用户密码。

1 个答案:

答案 0 :(得分:3)

您需要提供实际凭证:

let credential = EmailAuthProvider.credential(withEmail: email, password: password)