Richard
Richard

Reputation: 8935

Delete Firebase Users with Angular2/Ionic2

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

Upvotes: 2

Views: 2393

Answers (1)

KhoPhi
KhoPhi

Reputation: 9517

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()

Upvotes: 2

Related Questions