Danny Ogen
Danny Ogen

Reputation: 289

prevent firebase user from deleting himself

If I open a website with firebase installed and i execute this firebase.auth().currentUser.delete() in browser console after a user has logged in, the current user will be deleted. How can i prevent a user from calling the delete function. is there a way to disable this?

Upvotes: 5

Views: 1359

Answers (2)

Frank van Puffelen
Frank van Puffelen

Reputation: 600141

If you upgrade your project to Google Cloud Identity Platform (a drop-in upgrade) you can now disable:

  • Account creation
  • Account deletion

Both of these (and the ability to toggle protection against email enumeration attacks) can be set in the user actions panel of the Firebase console.


Previous answer 👇

There is no way to prevent a user from deleting their Firebase Authentication account. But whether you expose such functionality in your app is of course up to you.

It sounds a bit like an XY problem. What app-level problem are you trying to accomplish by disabling users from deleting their Firebase Authentication account?

Upvotes: 2

Dharmaraj
Dharmaraj

Reputation: 50930

You can now prevent users from deleting their own accounts by unchecking "Enable delete" in the Firebase console. This was available only in Cloud Identity Toolkit console before.

enter image description here

Using deleteUser() will throw an error "Firebase: Error (auth/admin-restricted-operation)."

Upvotes: 4

Related Questions