Sasha  Tsvigun
Sasha Tsvigun

Reputation: 351

It is impossible to delete a user from firebase

I am developing an application in which I want add a function to remove a user from Firebase. I follow the official documentation but I can not do it. I get a warning in the console

Error This operation is sensitive and requires recent authentication. Log in again before retrying this request.

Here is my code:

- (void)deleteUser {
   FIRUser *user = [FIRAuth auth].currentUser;
   [user deleteWithCompletion:^(NSError *_Nullable error) {
      if (error) {
          NSLog(@"Error %@", error.localizedDescription);
      } else {
          NSLog(@"Delete user");
      }
   }];

}

Perhaps somebody faced a similar problem, tell me how to solve?"

Upvotes: 1

Views: 906

Answers (1)

Mistrx丶
Mistrx丶

Reputation: 267

Look at Firebase api's doc in website, you can see your code to delete user in firebase must logined recently.

if you logined for a while. you must re authentication.

here is how to re auth :

FIRUser *user = [FIRAuth auth].currentUser;
FIRAuthCredential *credential;

// Prompt the user to re-provide their sign-in credentials

[user reauthenticateWithCredential:credential completion:^(NSError *_Nullable error) {
  if (error) {
    // An error happened.
  } else {
    // User re-authenticated.
  }
}];

in security sensitive operation such as(delete user, set password, set-email...), you must re auth first.

Upvotes: 2

Related Questions