【问题标题】:Missing or insufficient permissions firestoreFirestore 缺少或权限不足
【发布时间】: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


    【解决方案1】:

    您可以签出此 url 以进行 firebase 数据身份验证

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

    【讨论】:

    猜你喜欢
    • 2018-04-25
    • 2020-09-01
    • 2022-01-25
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 2020-11-24
    • 2018-09-12
    • 2021-12-31
    相关资源
    最近更新 更多