admin管理员组文章数量:1401171
I have these firebase rules
service cloud.firestore {
match /databases/{database}/documents {
match /anizations/{anizationId} {
allow create: if request.auth.token.superUser == true;
allow read, write: if request.auth != null && request.auth.uid in request.resource.data.userIds;
and a listener like this
FirebaseFirestore.instance
.collection(ORGANIZATIONS_PATH)
.where('userIds', arrayContains: userId)
.snapshots()
.handleError((onError) {
print('Org Service: naizations listener error');
print(onError);
})
.listen(_onOrganizationsChanged);
The documents show up as expected, but I'm also getting this error from the error handler:
the caller does not have permission to execute the specified operation.
How can I resolve this? Is it a bug that I'm both getting the documents and an error saying that he operation is not allowed?
I have these firebase rules
service cloud.firestore {
match /databases/{database}/documents {
match /anizations/{anizationId} {
allow create: if request.auth.token.superUser == true;
allow read, write: if request.auth != null && request.auth.uid in request.resource.data.userIds;
and a listener like this
FirebaseFirestore.instance
.collection(ORGANIZATIONS_PATH)
.where('userIds', arrayContains: userId)
.snapshots()
.handleError((onError) {
print('Org Service: naizations listener error');
print(onError);
})
.listen(_onOrganizationsChanged);
The documents show up as expected, but I'm also getting this error from the error handler:
the caller does not have permission to execute the specified operation.
How can I resolve this? Is it a bug that I'm both getting the documents and an error saying that he operation is not allowed?
Share Improve this question edited Mar 24 at 2:45 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges Recognized by Google Cloud Collective asked Mar 24 at 1:39 xerotolerantxerotolerant 2,0794 gold badges25 silver badges46 bronze badges 5- 1 My guess is that you're seeing results from the local cache, which were written there before you tightened your security rules. On Android, deinstall and reinstall the app to clear the cache. On iOS wipe the app data too. – Frank van Puffelen Commented Mar 24 at 2:51
- Have you solved the issue? – Alex Mamo Commented Mar 24 at 7:23
- @FrankvanPuffelen I ran flutter clean and rebuild the app (for macOS) but the errors persist. Is there an additional step to 'clearing the cache' on macOS besides 'flutter clean' and 'product -> clean build folder' in Xcode? – xerotolerant Commented Mar 24 at 13:00
- @AlexMamo I have not. I just realized on web that I'm not getting the data at all now. So the issue might be with the permissions themselves. Not sure why I would get the data on MacOS and not web. – xerotolerant Commented Mar 24 at 13:30
- I am not at all sure why changing the order of the rules worked but the errors have gone away so yeah. – xerotolerant Commented Mar 24 at 13:42
1 Answer
Reset to default 0I'd be lying if I said I know WHY this worked but I rearranged the rules to this
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /user_profiles/{userId} {
allow read: if request.auth != null;
}
match /{document=**} {
allow read, write: if request.auth.token.superUser == true;
}
match /anizations/{anizationId} {
allow read, write: if request.auth != null && request.auth.uid in resource.data.userIds;
match /{document=**} {
allow read, write: if request.auth.uid in (get(/databases/$(database)/documents/anizations/$(anizationId))).data.userIds;
}
}
}
}
本文标签: flutterFirestore says operation is not permitted but still returns documentsStack Overflow
版权声明:本文标题:flutter - Firestore says operation is not permitted but still returns documents - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744263908a2597853.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论