Reputation: 595
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
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