【发布时间】:2018-06-21 22:20:44
【问题描述】:
我有一个名为“读数”的顶级收藏。 Readings 中的每个文档都有一个名为“patientUid”的字段。
我有以下安全规则:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
//Takes a uid and returns true if it's the uid of the current user
function isTheUidOfCurrentUser(uid) {
return request.auth.uid == uid;
}
//A patient or one of their doctors can view their readings
match /readings/{reading} {
allow read, write: if isTheUidOfCurrentUser(resource.data.patientUid);
}
}
}
目前,如果用户读取其中一个读数,则一切正常,但由于某种原因用户无法创建读数。最奇怪的是控制台中的模拟器在尝试创建读数时甚至不显示规则匹配。
我在这里做错了什么。为什么规则只匹配读取,而不匹配写入?
【问题讨论】:
标签: google-cloud-firestore firebase-security