Firestore权限不足或不足

时间:2018-09-22 07:26:24

标签: firebase google-cloud-firestore google-cloud-functions angularfire2 firebase-security

我遇到错误: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.

但是,如果我将更新规则更改为: 允许更新,删除:如果isAuthenticated();效果很好

1 个答案:

答案 0 :(得分:-1)

您可以检出此URL以进行Firebase数据认证

https://firebase.google.com/docs/firestore/security/rules-conditions