【发布时间】:2021-11-05 01:39:33
【问题描述】:
在我的新应用中,Firestore 中有一系列需要成本的项目。以下是我用来保护这些文件的规则:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /projects/{project} {
function isSignedIn() {
return request.auth != null;
}
function isAdmin() {
return isSignedIn() && get(/databases/(database)/documents/users/$(request.auth.uid)).data.isAdmin) == true);
}
allow read: if isSignedIn();
allow create, update, delete: if isAdmin();
}
}
}
当我尝试部署此规则集时,我收到以下错误:
Error: Compilation errors in firestore.rules:
[E] 11:41 - Missing 'match' keyword before path.
[E] 11:51 - Forward slash '/' found where identifier or binding expected.
[E] 11:52 - mismatched input '(' expecting {'{', '/', PATH_SEGMENT}
[E] 11:62 - Missing 'match' keyword before path.
[E] 11:62 - Unexpected '/documents'.
[E] 11:78 - Forward slash '/' found where identifier or binding expected.
[E] 11:79 - mismatched input '$' expecting {'{', '/', PATH_SEGMENT}
[E] 11:98 - token recognition error at: '`'
[E] 23:1 - Unexpected '}'.
基本上它不喜欢get 行。但我是从 Firestore 文档 here 中得到的。有谁知道为什么这可能不起作用?
【问题讨论】:
-
我认为你在 get 行中的 true 之后有多余的 ")"。确保管理员之后的那个,我在文档中知道它,但只需检查它。
标签: firebase google-cloud-firestore firebase-security