【发布时间】:2019-08-20 12:06:27
【问题描述】:
我在 Firestore 集合中有名为“库存”的文档,其结构如下:
{
creator: string,
images: string[],
}
创建者字段是创建文档的用户的 uid。
在我的 Firestore 规则部分,我有以下规则:
service cloud.firestore {
match /databases/{database}/documents {
match /inventories/{inventoryid} {
allow read, write: if request.auth.id == resource.data.creator;
}
}
}
在我的离子应用程序中,我执行以下操作:
this.inventoryCollection = database.collection<Inventory[]>
('inventories', ref => ref.where('creator', '==', auth.currentUserId));
执行时出现以下错误:
Missing or insufficient permissions.
谁能看到我做错了什么?是我的规则有问题吗?还是我的代码调用 firestore 有问题?
【问题讨论】:
-
你检查过当前用户ID是否正确吗?也许用硬编码值进行测试?
-
@AndréKool currentUserId 是从 Firebase Auth 库中提取的,因此那里没有硬编码值。我已经在下面标记了答案。谢谢。
标签: angular firebase google-cloud-firestore ionic4 firebase-security