Firestore 权限缺失或不足 [英] Missing or insufficient permissions firestore
本文介绍了Firestore 权限缺失或不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误:Firebase 缺少权限或权限不足
I'm getting error: Firebase missing or insufficient permissions
代码:const demoCollectionRef = this.db.collection('items');return 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.
但是如果我将更新规则更改为:允许更新,删除:if 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/规则条件
这篇关于Firestore 权限缺失或不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文