我正在尝试构建一个包含聊天功能的应用程序,但出现错误消息:
[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.
我的 Firebase 规则:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid}{
allow write: if request.auth != null && request.auth.uid == uid;
}
match /users/{uid}{
allow read: if request.auth != null;
}
match /chat/{document=**}{
allow read: if request.auth != null;
}
}
}
enter image description here
如上图所示,当我写消息并发送时,它没有出现在屏幕上,错误信息写在终端
最佳答案
您可以按照以下规则制定规则。也是安全的
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
https://stackoverflow.com/questions/66240201/