What is the best way to delete a user from Firebase's Authentication using Angular and the user's id or email? I can't find a relevant function in AngularFireAuth.auth
1 Answer
In "pure" JavaScript you can do the following and user with mail [email protected] will be deleted from the Authentication list.
firebase.auth().signInWithEmailAndPassword("[email protected]", "abcd")
.then(function (info) {
var user = firebase.auth().currentUser;
user.delete();
});
In angular2+ you can do something like below,
remove(user: any, path: string) {
return this.db.list(this.PATH + path).remove(user.key) .then(() => {
firebase.auth().signInWithEmailAndPassword(user.email, user.password) .then(function (info) {
var user = firebase.auth().currentUser;
user.delete();
});
});
}
1 Comment
Elias
This way requires the user's password, since the signInWithEmailAndPassword function will be called. Can i get it somehow?