firebase setPriority permisions_denied

时间:2014-04-05 17:12:41

标签: firebase

文档:https://www.firebase.com/docs/javascript/firebase/setpriority.html

是不是缺少重要的东西?

我正在尝试通过某个auth用户更新该组的优先级。只有当我被认证为小组的所有者并且我不知道为什么以及如何仅仅因为我使用“membersCount”而更新所有AUTH用户的优先权时,我能够做到这一点。

// GROUPS
"groups": {
  "$subCategoryId": {      
    "$groupId": {
      // ONLY OWNER OF GROUP CAN UPDATE THE userId, name, hashTag, categoryId
      // 
      // The first init has to have userId, name, categoryId
      // 
      // Anyone can update the membersCount
      ".write": "newData.hasChildren(['userId','name','categoryId']) || !data.exists() || auth != null",
      "userId": {
        ".validate": "auth.uid == newData.val()"
      },
      "name": {
        ".validate": "newData.val() != '' && newData.val().length < 30 && (data.parent().child('userId').val() == auth.uid || !data.parent().child('userId').exists())"
      },
      "hashTag": {
        ".validate": "(data.parent().child('userId').val() == auth.uid || !data.parent().child('userId').exists())"
      },
      "categoryId": {
        ".validate": "newData.val() != '' && root.child('categories').child(newData.val()).exists() && root.child('subcategories').child(newData.val()).child($subCategoryId).exists() && (data.parent().child('userId').val() == auth.uid || !data.parent().child('userId').exists())"
      },
      "membersCount": {
        ".write": "auth != null && newData.isNumber() && (data.val()+1 == newData.val() || data.val()-1 == newData.val() )"  
      }
    }
  }    
},

当我尝试更新({'。gestity':2})时,我得到了:

未捕获错误:update()目前不支持更新.priority。

1 个答案:

答案 0 :(得分:0)

在这种情况下,错误消息与安全规则无关。您无法使用update()命令更新优先级。您可以使用setPriority(2)

来完成此操作

如果您想引用安全规则中的优先级,可以使用getPriority

执行此操作