gpt4 book ai didi

reactjs - 使用 react-redux-firebase 的 Firebase Firestore 查询

转载 作者:行者123 更新时间:2023-12-04 17:43:24 25 4
gpt4 key购买 nike

service cloud.firestore {
match /databases/{database}/documents {
match/projects/{project} {
allow read: if
get(/databases/$(database)/documents/projects/$(project)).data.uid ==
request.auth.uid;
allow create: if request.auth.uid == request.resource.data.uid;
allow update, delete: if request.auth.uid == resource.data.uid;
}
}
}

我在这里做查询:

firestoreConnect((props) => { 
return ([{ collection: 'projects', where: [["uid", "==", props.auth.uid]] }])
})

但是我得到一个错误:

Error with profile listener: Missing or insufficient permissions. Error: Missing or insufficient permissions. at new FirestoreError (index.cjs.js:402).

当我使用模拟器在路径中输入文档 ID 进行检查时,我获得了读取权限。我没有得到我错的地方。也许在查询中。

当我将规则更改为:

allow read : if resource.data.uid == request.auth.uid;

没有错误,显示数据。

为什么它会发生是错误还是我做错了什么?我知道 firebase 规则不是过滤器。

最佳答案

您正在单独阅读文档(而且是不必要的),我认为规则引擎无法评估和验证查询在这种情况下永远不会返回不允许的文档。

试试这个:

allow read: if resource.data.uid == request.auth.uid;

关于reactjs - 使用 react-redux-firebase 的 Firebase Firestore 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53357647/

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