Firebase: removeUser() but need to remove data sto

2020-04-16 03:15发布

I'm using Firebase and need to add a removeUser() function to remove a user account however there is also data stored under that uid in the database. Is it possible for the removeUser() function to also remove that data or is the only way to run another Firebase function (remove()) as a callback?

Thanks, J

标签: firebase
1条回答
够拽才男人
2楼-- · 2020-04-16 03:57

Firebase doesn't store any data about your users in your database. So if there is data about the user in your Firebase database, it is because your application stored it there. Likely you store it there when you called createUser(), as recommended in the Firebase programming guide for storing user data.

For this reason it makes sense that it's also the responsibility of your application to remove the data about a user when it calls removeUser(). This can be as simple as:

function myRemoveUser(uid, email, password) {
  ref.removeUser({ email: email, password: password }, function(error) {
    if (!error) {
      ref.child('users').child(uid).remove();
    }
  });

}

Look at the docs for removeUser() to see how it handles errors/

查看更多
登录 后发表回答