简体   繁体   English

无法从Firebase中删除用户

[英]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. 我正在开发一个应用程序,我想在其中添加功能以从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?" 也许有人遇到类似的问题,告诉我如何解决?”

Look at Firebase api's doc in website, you can see your code to delete user in firebase must logined recently. 在网站上查看Firebase api的文档,您可以看到您要删除的代码在Firebase中必须最近登录。

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. 在对安全敏感的操作中,例如(删除用户,设置密码,设置电子邮件...),必须首先进行身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM