I'm working in a project with FirebaseUI and I want to give the user ability to delete his account. I've used this code from Firebase Documentation:
@IBAction func deleteTheAccountButtonHasBeenTapped(_ sender: Any) {
let user = Auth.auth().currentUser
user?.delete { error in
if let error = error {
print(error)
} else {
self.defaults.set(false, forKey: "isUserLoggedIn")
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let LoginVC = storyBoard.instantiateViewController(withIdentifier: "LoginVC") as! LoginVC
self.present(LoginVC, animated:true, completion:nil)
}
}
}
unfortunately I keep getting the error:
Error Domain=FIRAuthErrorDomain Code=17014 "This operation is sensitive and requires recent authentication. Log in again before retrying this request." UserInfo={NSLocalizedDescription=This operation is sensitive and requires recent authentication. Log in again before retrying this request., FIRAuthErrorUserInfoNameKey=ERROR_REQUIRES_RECENT_LOGIN}
it requires to re-authenticate the current user, anyone can help me on this?