Firebase: removeUser() but need to remove data stored under that uid

后端 未结 1 1505
礼貌的吻别
礼貌的吻别 2021-01-22 05:00

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 da

相关标签:
1条回答
  • 2021-01-22 05:52

    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/

    0 讨论(0)
提交回复
热议问题