【问题标题】:Security Rules - lists of data that can be read?安全规则 - 可以读取的数据列表?
【发布时间】:2013-08-31 17:33:52
【问题描述】:

所以我的应用程序有许多用户共享的“对话”。 “对话”有很多“用户”。

我能够在特定对话中使用模拟器获得授权作者“.read”,但我不确定在以用户身份登录时如何获取对话列表 - 我无法使用 @ 'conversations' 上的 987654321@,因为 .read 在'conversations' 上是不允许的,只能在他们的一些孩子上使用,具体取决于登录的用户。

我应该如何进行?

谢谢!

【问题讨论】:

    标签: firebase firebase-security


    【解决方案1】:

    我们不建议使用安全规则来实现记录过滤。您可以将对话列表存储在全局列表下,然后将这些对话的 ID 存储在有权访问它们的每个用户下。这意味着您还必须确保在发生更改时更新每个用户的对话列表。

    /conversations
      <conversation-id-1>
      <conversation-id-2>
    /users
      <user-1>
        /conversations
          <conversation-id-1>: true
      <user-2>
        /conversations
          <conversation-id-2>: true
    

    在 /users/user1/conversations 上执行 .on("child_added") 将使您能够访问用户有权访问的所有对话。确保适当地设置顶级对话列表的权限。

    请参阅https://www.firebase.com/blog/2013-04-12-denormalizing-is-normal.html,了解有关如何在 Firebase 中构建数据的更多背景信息。

    【讨论】:

    • 那么,对于会话 ID,您必须一一请求它们才能获得有关这些会话的信息?
    猜你喜欢
    • 2020-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 2021-08-12
    • 2020-07-11
    • 2021-01-19
    • 1970-01-01
    相关资源
    最近更新 更多