2017-02-18 50 views
1

我正在開發一個應用程序,我在其中添加了一個從Firebase中刪除用戶的功能。我遵循官方文件,但我無法做到。我在控制檯中收到警告無法從Firebase中刪除用戶

錯誤此操作非常敏感,需要最近的認證。在重試此請求之前再次登錄。

這裏是我的代碼:

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

}

也許有人遇到了類似的問題,告訴我怎麼解決」的網站

+0

我留言解釋了這條消息的原因當你發佈[這完全相同的問題](http://stackoverflow.com/questions/41790469/error-when-deleting-a-user-from-the-database -firebase)幾個星期前。如果評論不明確,那麼請隨時尋求更多幫助。在Stack Overflow上重新發布相同的問題幾周後是不可接受的。 –

回答

1

看火力地堡API的文檔,你呢?可以看到你的代碼在firebase中刪除用戶最近必須登錄。

如果你登錄了一段時間,你必須重新驗證entication。

這裏是如何重新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. 
    } 
}]; 

在安全敏感操作,例如(刪除用戶,設置密碼,設置電子郵件...),則必須重新AUTH第一。