Firebase规则:意外行为

时间:2019-03-22 04:08:46

标签: firebase firebase-realtime-database firebase-authentication

如果用户的uid列在“游戏/ $ game / seatedPlayers / $ uid”下,我试图允许用户写入“游戏/ $ game /玩家”节点。我希望这可以在我提供的示例中起作用,但是尽管尝试了几种规则变体,但仍无法允许写入。规则保存无误,模拟器也确认了我的结果。

Firebase规则:

{
  "rules": {
    "games": {
      "$game": {
        ".read": true,
        "players": {
          ".write": "root.child('games/' + $game + '/seatedPlayers/' + auth.uid).exists()"
        }
      }
    }
  }
}

记录:

-games
    -$game
        -players
            -some
            -more
            -nodes
                -of various depths
        -seatedPlayers
            -$uid
                -true

模拟结果

Type    update
Location    games/$game/players/test
Data    { "key": "value" }
Auth    { "provider": "anonymous", "uid": "$uid" }
Admin   false

Line 7 (/games/$game/players)
write: "root.child('games/' + $game + '/seatedPlayers/' + auth.uid).exists()"

0 个答案:

没有答案