首页 文章

从Firebase中删除特定用户

提问于
浏览
5

有没有办法从firebase获取特定的用户帐户然后将其删除?

例如:

// I need a means of getting a specific auth user.
var user = firebase.auth().getUser(uid);
// Note the getUser function is not an actual function.

之后,我想删除该用户及其他数据:

// This works
user.delete().then(function() {
   // User deleted.
   var ref = firebase.database().ref(
      "users/".concat(user.uid, "/")
   );
   ref.remove();
});

Firebase Documentation表示如果用户当前已登录,则可以将其删除:

firebase.auth().currentUser.delete()

My aim is to allow logged in admin user to delete other users from the system.

1 回答

  • 3

    Update: there is now a Firebase Admin SDK that runs with administrative privileges and allows you to delete users.

    当前删除用户的唯一方法是首先以该用户身份登录 . 目前没有API可以在没有该用户首次登录的情况下删除用户 .

    我们知道许多应用都需要此功能,并且正在努力添加它 . 但是像往常一样,我们没有关于什么时候可用的时间表 .

    与此同时,一种常见的方法是将白名单/黑名单保留在Firebase数据库中,并根据该列表进行授权 . 见How to disable Signup in Firebase 3.x

相关问题