本文介绍了Firestore权限不足或不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到错误:Firebase丢失或权限不足

I'm getting error: Firebase missing or insufficient permissions

代码:const demoCollectionRef = this.db.collection('items');返回demoCollectionRef.add(item);

Code : const demoCollectionRef = this.db.collection('items'); return demoCollectionRef.add(item);

我认为此错误是由于angularfire2的.add方法引起的.

I think this error is because of .add method of angularfire2.

Firestore规则:

Firestore Rules:

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();效果很好

But if I change the update rule to:allow update, delete: if isAuthenticated(); it works fine

推荐答案

您可以检出此URL以进行Firebase数据身份验证

You can checkout this url for firebase data authentication

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

这篇关于Firestore权限不足或不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 09:55