我正在学习 Firestore 并构建了一个有角度的应用程序。我正在使用 Firebase 身份验证,但无法确定用于允许用户访问其数据的规则。例如,一个产品集合,每个产品都有一个 userId,实际上是他们的电子邮件地址。
我当前的规则如下,但不起作用(我已经尝试了基于文档、stackoverflow 等所能想到的一切):
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userEmail} {
allow read, write: if request.auth != null;
}
match /products/{userId}{
allow read, write: if request.auth.uid.userEmail == userId
}
}
}
Run Code Online (Sandbox Code Playgroud)
我所做的唯一有效的事情(即我拿回所有产品)是如果我进行 match/{document=**) ,它将它向任何不是我想要的人开放。:)
有任何想法吗?
编辑:以防有人想知道角度代码。再说一次,如果我设置规则允许任何我做的事情取回数据。如果我限制它,到目前为止我什么也得不到。所以,我知道代码有效(getAll),因此一定是规则不正确。
编辑:我更新了代码,以便在从商店请求所有产品数据之前将用户电子邮件写入控制台。它成功输出了用户的电子邮件。
import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';
import { AngularFireAuth } from '@angular/fire/auth';
import { Product } from '../models/product.model';
@Injectable({
providedIn: 'root'
})
export class ProductsService { …Run Code Online (Sandbox Code Playgroud) javascript firebase-security angularfire firebase-authentication google-cloud-firestore
我从 angular.io 网站分叉了本教程: https: //angular.io/start
其中一个步骤是创建一个新组件,因此我右键单击应用程序文件夹,但没有像其网站上的屏幕截图中所示的“Angular Generator”选项。我缺少什么?
我应该看到这个:
我有一个ASP.Net应用程序,它引用一个带有一些可重用代码的程序集(常用工具,数据访问等).装配参考IBM.Data.DB2.dll.但是,我没有在我的应用程序中使用DB2,IBM.Data.DB2.dll它只是一个依赖项(如果应用程序需要连接到DB2).最近,我遇到了以下错误:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.ReportingServices.Interfaces, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Unity.AutoRegistration.AutoRegistration.<ApplyAutoRegistration>b__5(Assembly a)
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Unity.AutoRegistration.AutoRegistration.ApplyAutoRegistration()
Run Code Online (Sandbox Code Playgroud)
整个应用程序中包含Microsoft.ReportingServices.Interfaces的唯一文件是该IBM.Data.DB2.dll文件.在部署应用程序时,我不需要SQL Server或本地安装SQL Server的开销少得多.请记住,我需要使用具有依赖性的程序集,IBM.Data.DB2.dll并且此错误在过去没有发生过,它似乎是最近的.
我尝试过绑定重定向,通过Nuget安装Microsoft.ReportingServices.Interfaces都无济于事.
有谁知道为什么会出现这个错误,更重要的是......如何解决它?