Habibi
Habibi

Reputation: 595

Remove Existing Account from Firebase 3

In pre-Firebase 3, there is a function "removeUser" to remove an existing account with email&password (https://www.firebase.com/docs/web/api/firebase/removeuser.html)

But I can't seem to find a similar function in Firebase 3. Is it no longer possible to do it?

Upvotes: 2

Views: 3828

Answers (1)

adolfosrs
adolfosrs

Reputation: 9389

You are looking for the user.delete() function. Here is the documentation.

var user = firebase.auth().currentUser; 
user.delete().then(function() {
  // User deleted.
}, function(error) {
  // An error happened.
});

Note that this is a critical operation and therefore this will need a previous call to reauthenticate:

var user = firebase.auth().currentUser;
var credential = firebase.auth.EmailAuthProvider.credential(user.email, userProvidedPassword);

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

user.reauthenticate(credential).then(function() {
  // User re-authenticated.
}, function(error) {
  // An error happened.
});

Upvotes: 2

Related Questions