【发布时间】:2014-09-09 07:57:33
【问题描述】:
使用 Firebase 安全规则,我如何检查兄弟值以确定 newData 是否有效?
在我的应用程序中,每个game 都有moves 的列表。这里的游戏是1405584062293:
当一个新的动作被提交时,我想参考已经玩过的动作来验证它。对于初学者来说,玩家应该只能下每第二步(玩家一可以从索引0 开始下偶数,玩家二可以下奇数)。
由于每一步的关键是一个未知的随机字符串(根据this recommendation in the docs),我不知道如何检查上一步。我也不知道如何计算现有的移动次数。
这是我的结构:
{
"rules":{
".read":true,
"games":{
"$game":{
"moves":{
"$move":{
".write":"auth !== null",
// Something along these lines would get me going...
".validate":"data.parent().keys.count % 2 == 0"
}
}
}
}
}
}
实际上游戏规则要复杂得多,我希望我需要使用 Firesafe 或类似的解决方案,但现在我想知道如何实现这些以及其他如此简单的规则。
【问题讨论】:
标签: firebase firebase-security