Firestore 规则说文档获取功能是错误的
Firestore rules saying document get function is wrong
在我的新应用程序中,有一系列项目在 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。有谁知道为什么这可能不起作用?
你有一些小错误:
- 你有两个不需要
)
- 你忘记了
database
之前的 $
试试这个:
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();
}
}
}
在我的新应用程序中,有一系列项目在 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。有谁知道为什么这可能不起作用?
你有一些小错误:
- 你有两个不需要
)
- 你忘记了
database
之前的
$
试试这个:
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();
}
}
}