【问题标题】:How to restrict users to push data or adding child more than one to firebase database child如何限制用户推送数据或将多个子级添加到 Firebase 数据库子级
【发布时间】:2017-08-17 13:17:32
【问题描述】:

在 firebase 安全规则中,我们如何限制用户向数据库推送多个数据?

我一直在尝试,但没有成功

   {
    "rules": {
    ".read": false,
    ".write": false,    
    "voters": {

  // restrict user to adding child more than one in this path
  // one user only alowed to add one child
  ".read": true,
  ".write": "auth !== null",
  ".validate": "newData < 2",
    "$votersuid": {
    ".read": true,
    ".write": "auth.uid == $votersuid",
    }   
  },
 }

}

【问题讨论】:

    标签: javascript json security firebase rules


    【解决方案1】:

    您可以向您的节点添加一个布尔值,然后您可以像这样进行测试".write": "root.child('node_name').child('can_write').val() === true

    【讨论】:

    • 感谢您的回复我仍然需要测试它,很遗憾我无法投票赞成您的答案,因为我的声誉低于 15。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 1970-01-01
    • 2023-01-25
    • 2017-07-31
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    相关资源
    最近更新 更多