Firestore FirebaseError:权限缺失或不足

时间:2021-06-16 15:22:55

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

我的 Firestore 安全规则有问题。我有以下规则:

ERROR FirebaseError: Missing or insufficient permissions.
at new e (prebuilt-ac190846-5fb4dac2.js:188)
at prebuilt-ac190846-5fb4dac2.js:10430
at prebuilt-ac190846-5fb4dac2.js:10431
at e.onMessage (prebuilt-ac190846-5fb4dac2.js:10453)
at prebuilt-ac190846-5fb4dac2.js:10370
at prebuilt-ac190846-5fb4dac2.js:10401
at prebuilt-ac190846-5fb4dac2.js:15132
at ZoneDelegate.invoke (zone-evergreen.js:372)
at Zone.run (zone-evergreen.js:134)
at zone-evergreen.js:1276

他们似乎在 Firestore 规则操场上工作。当我期望他们成功时,他们成功了,但在我的应用程序中,我收到以下错误:

return this.firestore.collection<Project>('projects', query => {
  return query
    .where('members', 'array-contains-any', [
      { user: this.authService.getCurrentUserRef(user), role: MemberRole.OWNER },
      { user: this.authService.getCurrentUserRef(user), role: MemberRole.DEVELOPER },
      { user: this.authService.getCurrentUserRef(user), role: MemberRole.CLIENT }
    ])
    .where('archived', '==', archived);
})
  .snapshotChanges()
  .pipe(mergeMap(projects => {
    return combineLatest(projects.map(project => {
      const data = project.payload.doc.data();
      return this.userService.one(project.payload.doc.data().owner.id).pipe(map(owner => ({
        id: project.payload.doc.id,
        name: data.name,
        owner: owner?.displayName ?? 'Unknown',
        ownerId: owner.uid,
        description: data.description,
        status: data.status,
        archived: data.archived
      })));
    }));
  }));

我的问题基本上是:我的规则有什么问题吗?他们为什么能在操场上取得成功?如何调试这些规则?目前它很痛苦。

由于权限错误而失败的代码如下:

{{1}}

PS:我可以在我的应用程序中编辑单个项目视图,但不能编辑所有项目视图,即使我有 where 过滤器来检查您是否是项目的成员/所有者。

0 个答案:

没有答案