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

发布于 2025-01-25 00:15:28 字数 308 浏览 2 评论 0原文

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

这是我的数据库结构:

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

这些是我的数据库规则:

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

}

I've created a list of banned users in my realtime Database and I want to make them impossible to log-in, I know I can use the database rules, but I don't know how, can someone help me?

This is my database structure:

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

Those are my database rules:

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

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撑一把青伞 2025-02-01 00:15:28

您需要

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

”实际上,您不会“使它们无法登录”,因为这是不可能的,但是您可以防止它们从数据库写入/阅读。

You need to reference data in other paths as follows:

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

Note that actually you don't "make them impossible to log-in", because this is not possible, but you prevent them writing to/reading from your database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文