2

I am using Ionic2/Angular2, and have been looking for an example of how to delete users from Firebase.

If anyone has any examples, please can you help?

Thank you

1 Answer 1

2

I have two options for you:

Drop down to the native Firebase SDK

As in, you can follow the steps in this SO answer to acquire the current user, and remove it.

That will allow you do something along the lines of this, from the docs:

var user = firebase.auth().currentUser;

user.delete().then(function() {
  // User deleted.
}, function(error) {
  // An error happened.
});

Try this snippet

Using AngularFire2, how about this approach?

    af.auth
      .first()
      .subscribe(authState => {
        console.log(authState);
        authState.auth.delete()
          .then(_ => console.log('deleted!'))
          .catch(e => console.error(e))
      });

Don't forget the .first()

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I am using AngularFire2, so will go with that. Working for me.
Thanks for the answer. The delete works like a charm :) But how about the open subscriptions that I have for that user I deleted? I'me getting "permission_denied" on all open subscriptions :(

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.