【问题标题】:Get a document name based in the rules根据规则获取文档名称
【发布时间】:2018-04-10 16:18:47
【问题描述】:

我正在寻找在我的 Firestore 数据库中添加一条规则。 规则是如果文档等于request.auth.uid,则允许写入文档。 我不知道如何在规则中搜索我的文档名称。

这是我缺少这部分的代码:

service cloud.firestore {
  match /databases/{database}/documents {
  match /users/{anyDocument} {
      allow write: if request.auth != null && request.auth.uid == ?????????;
      allow read
    } 
  }
}

【问题讨论】:

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


    【解决方案1】:

    您的问题不清楚,但我假设您只想强制编写一个 id 等于用户身份验证 id 的文档。

    match /users/{anyDocument} {

    由于这一行,文档 id 将被设置为变量anyDocument,所以这是您要检查的内容。

    allow write: if request.auth != null && request.auth.uid == anyDocument;

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 1970-01-01
      • 2018-12-27
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 2019-04-10
      • 1970-01-01
      • 2021-11-26
      相关资源
      最近更新 更多