4
因此,我使用Firebase制作日历应用程序,并且遇到了一些小问题。基于其他相关数据无效的Firebase规则给予阅读权限
我的数据库结构是这样的:
- calendar
- $year
- $month
- $day
- $uid
- name
- arrivalStatus
- users
- $uid
- name
- team
所以我想要做的是,人们在同一个团队必须能够在日历中读取对方的条目。我给自己定的规则像这样:
{
"rules": {
"users": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
},
"calendar": {
"$year":{
"$month":{
"$day":{
"$uid":{
".read": "auth != null &&
root.child('users/'+auth.uid+'/team').exists() &&
root.child('users/'+$uid+'/team').val() == root.child('users/'+auth.uid+'/team').val()",
".write": "auth != null && auth.uid == $uid"
}
}
}
}
}
}
}
但无论出于何种原因,通过模拟运行时,该请求被批准,不管你是什么队。我错过了明显的东西吗?
编辑:
所以基本上我们假设这个数据集:
-firecalender
-calendar
-2016
-9
-30
-gsdfgd
-Name: "MG"
-Status:"PM"
-users
-abcd
-name: "Tester"
-team: "bc"
-efg
-name: "noteam"
-team: "funny inc"
-gsdfgd
-name: "bossman"
-team : "bc"
在这种情况下,ABCD应该能够读取里面日历每gsdfgd的信息,但EFG应该被拒绝访问。
您是否尝试过在安全规则更改$ UID的名字。现在你在两个地方使用$ uid,也许firebase看不到区别。 –
您可以显示您想要失败的操作(包括确切的路径,数据和活动uid)以及它成功的基础数据吗? –
如果UID为abcd或gsdfgd,则应该允许使用基本日历/ 2016/9/30/gsdfgd /但如果UID为efg则应拒绝 – Fireprufe15