我有三个UITextField,分别输入旧密码,新密码和确认密码。我获得了警报成功,但是我的用户密码未更改。有任何想法吗?谢谢。
@IBAction func buttonPressed(_ sender: UIButton) {
if password != confirmPassword {
createAlert(title: "Error", message: "Passwords do not match")
} else {
let user = Auth.auth().currentUser
let credential: AuthCredential = EmailAuthProvider.credential(withEmail: (user?.email)!, password: oldPassword!)
user?.reauthenticateAndRetrieveData(with: credential, completion: {(authResult, error) in
if error != nil {
self.createAlert(title: "Error", message: "failed")
}else{
Auth.auth().currentUser?.updatePassword(to: self.password!) { (error) in
print("Error")
}
self.createAlert(title: "Success", message: "Password change successful!")
}
})
}
}