【发布时间】:2019-02-26 11:57:36
【问题描述】:
我收到错误消息:Firebase 缺失或权限不足
代码: const demoCollectionRef = this.db.collection('items'); 返回 demoCollectionRef.add(item);
我认为这个错误是由于 angularfire2 的 .add 方法造成的。
Firestore 规则:
function isAuthenticated() {
return request.auth.uid != null;
}
function isAdmin() {
return request.auth.token.admin == true;
}
allow create: if isAuthenticated();
allow update, delete: if isAdmin(); // .add method checks update rules
// at the place of checking the create rules, which make it send error.
但如果我将更新规则更改为: 允许更新、删除: if isAuthenticated();它工作正常
【问题讨论】:
标签: firebase google-cloud-firestore google-cloud-functions angularfire2 firebase-security