firebase - Firestore 中的组查询设置规则中的问题(错误代码=PERMISSION_DENIED)
问题描述
我很确定,我正在尝试通过谷歌控制台设置 firestore 规则我在颤振中使用组查询,但我得到了同样的错误
我有 Notes(collection)-> CSC(DOC) ->sem1(collection) ->(doc)->subject1="主题值 (field) | |->ECE(DOC) ->sem1(collection) -> (doc)->subjectece="the value of subject ece of subject" (field)
我的错误:
W/Firestore(16933): (22.1.2) [Firestore]: Listen for Query(target=Query( collectionGroup=Notes order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
E/flutter (16933): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.
E/flutter (16933):
我曾尝试对 Firestore 规则进行 20 多次更改但同样的错误:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /calculatorApp/{userId} {
allow read :if request.auth != null&& request.auth.uid == userId;
allow create: if request.auth != null;
allow delete: if request.auth != null && request.auth.uid == userId;
allow write:if request.auth != null && request.auth.uid == userId;
allow update:if request.auth != null &&request.auth.uid == userId;
}
match /{path=**}/Admin/{documents}{
allow read, write: if false;
}
match /{path=**}/subsettings/{subsettingsId}{
allow read, write: if false;
}
match /{path=**}/notes/{notesId} {
allow read, write: if false;
}
match /{path=**}/sem1/{sem1Id} {
allow read, write: if false;
}
}
}
我的颤振代码:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
class Testdb extends StatefulWidget {
@override
_TestdbState createState() => _TestdbState();
}
class _TestdbState extends State<Testdb> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: IconButton(
icon: Icon(Icons.ac_unit),
onPressed: () async {
FirebaseFirestore.instance
.collectionGroup("Notes")
.snapshots()
.listen((value) => value.docs.forEach((element) {
print(" ELEMENT ${element.id}");
print(" ELEMENT ${element.data()}");
;
}));
})),
);
}
}
伙计们请帮助我是初学者,也是firestore的新手,我在firestore的设定规则内遇到了问题
解决方案
推荐阅读
- r - 当需要行上的特定条件时,如何替换 R 中的双循环?
- c++ - 如何使用 C++ 文件系统库将文件复制到另一个目录
- reactjs - 用星号替换字符反应输入
- ios - 织物崩溃 iOS
- angular - 从验证中重置 Angular 7 Reactive
- angular - 我将如何设置默认单选按钮检查并知道从反应形式的单选组中检查了哪个单选按钮?
- javascript - AutoCompleteEditor(react-data-grid)在 chrome 中不起作用
- java - 在 debian 上安装 oracle java8
- wordpress - 401 Unauthorized response only on new version of chrome/firefox browser when using the WP-API Basic-Auth plugin
- arrays - Angular First SQL 从数组 1 中的数据库检索键:在屏幕上,需要显示来自 array2 的文本,其键对应于 array1 值