gpt4 book ai didi

Firebase 规则根据其他相关数据不工作授予读取权限

转载 作者:行者123 更新时间:2023-12-03 22:05:48 24 4
gpt4 key购买 nike

所以我正在使用 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 应该能够读取 Calendar 中每个 gsdfgd 的信息,但应该拒绝访问 efg。

最佳答案

我认为您的问题是您正在使用 ==而不是 === .

示例链接:https://firebase.google.com/docs/database/security/user-security

关于Firebase 规则根据其他相关数据不工作授予读取权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39788939/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com