Firebase 设置文档及其所有子集合的权限
我得到一个错误:Firebase 设置文档及其所有子集合的权限,firebase,google-cloud-firestore,firebase-security,Firebase,Google Cloud Firestore,Firebase Security,我得到一个错误: FirebaseError:尝试查看子集合中的文档时,权限缺失或不足。我正在尝试获取子集合“设置”中的文档“字符” systemsCol() .doc(localStorage.getItem("systemId")) .collection('settings') .doc('character') 如何设置每个“系统”文档的所有项目和子文档 这是我的权限 service cloud.firestore { function authed (auth,
FirebaseError:尝试查看子集合中的文档时,权限缺失或不足。我正在尝试获取子集合“设置”中的文档“字符”
systemsCol()
.doc(localStorage.getItem("systemId"))
.collection('settings')
.doc('character')
如何设置每个“系统”文档的所有项目和子文档
这是我的权限
service cloud.firestore {
function authed (auth, data){
return auth.uid == data.owner.uid || auth.token.email in data.collaborators;
}
match /databases/{database}/documents {
match /systems {
allow read, write:
if request.auth.uid != null;
match /{systemId} {
allow list, create:
if request.auth.uid != null;
allow get, update, delete:
if authed(request.auth, resource.data);
}
match /{systemId}/{document=**} {
allow read, write:
if authed(request.auth, resource.data);
}
}
}
}
也试过
service cloud.firestore {
function authed (auth, data){
return auth.uid == data.owner.uid || auth.token.email in data.collaborators;
}
match /databases/{database}/documents {
match /systems {
allow read, write:
if request.auth.uid != null;
match /{systemId} {
allow list, create:
if request.auth.uid != null;
allow get, update, delete:
if authed(request.auth, resource.data);
match /{document=**} {
allow read, write:
if authed(request.auth, get(/systems/{systemId}).data);
}
}
}
}
}
你的规则有很多条件,你在这里什么都没说,所以不可能准确地指出哪里出了问题。我建议您消除除一个以外的所有条件,确保其中一个有效,然后继续添加条件,直到它以您想要的方式工作。对不起,让我澄清一下。我有一个叫做系统的高级集合。每个都可以有一个所有者和许多合作者。(由所有者的uid和合作者的电子邮件验证)系统集合和每个系统文档的身份验证权限有效,但我在尝试使用同一帐户访问子集合时遇到问题。您的规则有很多条件,您在这里没有说明,因此,不可能准确地找出问题所在。我建议您消除除一个以外的所有条件,确保其中一个有效,然后继续添加条件,直到它以您想要的方式工作。对不起,让我澄清一下。我有一个叫做系统的高级集合。每个都可以有一个所有者和许多合作者。(由所有者的uid和合作者的电子邮件验证)系统集合和每个系统文档的身份验证权限有效,但我在尝试使用相同帐户访问子集合时遇到问题。