我在Cloud Firestore上有一个简单的聊天应用程序,它有以下安全规则,只允许用户在应用程序中“加入”聊天室时才能在聊天室中发送消息:
match /hangouts/{hangout}/messages/{message} {
allow create, write, update, read: if exists(/databases/$(database)/documents/users/{userId}/hangout/{hangout});
}如果用户在Firestore上的集合中有一个hangoutID,那么他们应该被允许向该hangoutID发送消息。但是,我仍然收到错误消息:
Write at hangouts/ChIJPRVm2R7H54kRKLP2ttsuUko/messages/17225E70-B708-4033-AE5A-D0CBBD1BC69F failed: Missing or insufficient permissions.我还有另外两条与闲逛有关的规则。有没有可能这些都是干扰?
match /hangouts/{hangout} {
allow read, update, write, create: if request.auth.uid != null;
}
match /hangouts/{hangout}/members/{userId} {
allow read: if request.auth.uid != null;
allow create, update, write, delete: if request.auth.uid == userId;
}第一个是人们可以创建和查看聊天室,第二个是允许人们加入聊天室。
我做错了什么?我对这个概念还不是很熟悉。
谢谢!!
发布于 2019-05-10 07:54:25
看起来您没有正确地对文档路径进行变量替换。在匹配部分,您使用{花括号}来指示通配符的位置,但在路径表达式中,您使用通配符的名称,如$(this)。
/databases/$(database)/documents/users/$(userId)/hangout/$(hangout)https://stackoverflow.com/questions/56068834
复制相似问题