且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用户级别的Firebase Cloud Firestore中的身份验证问题

更新时间:2023-12-05 20:04:58

如果您将文档保存用户的uid存储在文档中(例如),例如 createdBy 请执行以下操作:

If you store in the document the uid of the user who saved the doc in a field called (for example) createdBy you can do as follows:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read: if request.auth.uid != null && resource.data.createdBy == request.auth.uid;
      allow write: .... 
    }
  }
}