2

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 1

4

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(); 
    }); 
  }); 
}
Sign up to request clarification or add additional context in comments.

1 Comment

This way requires the user's password, since the signInWithEmailAndPassword function will be called. Can i get it somehow?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.