如何使用规则禁止Firebase实时数据库中的用户?

s1ag04yj  于 2023-03-19  发布在  其他
关注(0)|答案(1)|浏览(115)

我在我的实时数据库中创建了一个禁止用户列表,我想让他们无法登录,我知道我可以使用数据库规则,但我不知道如何,有人能帮助我吗?
这是我的数据库结构:

/banned-users:
    /UserId1:True
    /UserId2:True

这些是我的数据库规则:

{
    "rules": {
    ".read": true,
    ".write": true
      }

}
im9ewurl

im9ewurl1#

需要按如下方式引用其他路径中的数据:

{
  "rules": {
    "thepath": {
          ".read": "root.child('banned-users').child(auth.uid).val() !== true"
          ".write": "root.child('banned-users').child(auth.uid).val() !== true"
      }
    }
}

请注意,实际上您并没有“使他们无法登录”,因为this is not possible,但您阻止他们写入/阅读您的数据库。

相关问题