0

I am building a website where a certain "admin" user can delete any other user's account. I already have the code in for checking whether a user is an admin user, but I cannot find a way to delete any user's account in Firebase with their email address (you can only delete your own account). I saw this post: Link to Stackoverflow Post. But, this states that the only solution is by using the Firebase Admin SDK (but if I understood that well that is only useful on a server??). Is there maybe another way to delete any user without using the Admin SDK?

Code for deleting your own account (just as a reference):

var user = firebase.auth().currentUser;

user.delete().then(function() {
  // User deleted.
}).catch(function(error) {
  // An error happened.
});

Thank you.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Rosalie W
  • 359
  • 4
  • 16
  • If there was another way, the question you found would've mentioned that. It helps to realize that: 1) the Firebase Authentication SDK has no way to identify a user as an administrator, 2) allowing an arbitrary user to delete another user's account would be a huge security risk. – Frank van Puffelen Mar 11 '20 at 01:12

1 Answers1

1

There is no way that any user can delete another user's account using any client SDK. You must use the Admin SDK on a backend for that.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441