【问题标题】:Firebase rule - Permission DeniedFirebase 规则 - 权限被拒绝
【发布时间】:2020-08-16 17:35:35
【问题描述】:

我有一个firebase数据,其数据结构如下:

{
  "users": {
     "123456": {
         "Name": "ABC"
         "uid": "123456"
     }
  }
  "Orders":{
     "987654": {
         "Customer ID": "123456"
         "Other Details":  *****
     }
  }
}

其中 users 是我的数据库中的用户列表。订单是每个用户下的订单。显示的用户 ID 和订单 ID 是虚拟的。它们是由按键生成的。现在,如果“客户 ID”与用户 ID 相同,则用户可以读取订单。为此,我有以下 Firebase 规则:

"Orders":{
  ".indexOn": ["Customer ID"],
  "$Orders_id": {
    ".write": "((root.child('Orders/'+$Orders_id+'/Customer ID').val() === auth.uid && auth != null) ||(auth != null && !data.exists())",
    ".read": "root.child('Orders/'+$Orders_id+'/Customer ID').val() === auth.uid && auth != null "
  }
}

但是,我收到“权限被拒绝”消息。数据的第一次写入是完美的。谁能指导一下。

【问题讨论】:

    标签: firebase firebase-realtime-database firebase-security


    【解决方案1】:

    您确定从编码中读取/写入正确的节点吗?
    您可以在此节点中访问读/写 => Orders/{Orders_id}
    您无法访问此节点中的读/写 => Orders

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-27
      • 1970-01-01
      • 2019-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-25
      相关资源
      最近更新 更多