[英]Firestore security rules how to check if document was created by user (is owner)
我有一個具有兩個集合的firestore數據庫:“筆記”(每個文檔存儲每個筆記的內容和authorId(對應於當前登錄的用戶uid))和“用戶”(用於存儲用戶名)每個文檔的ID是用戶的uid。 這樣,便箋的作者就可以在Firestore中連接到用戶。 我正在嘗試制作一個Web應用程序,其中僅顯示用戶創建的注釋(authorId == uid),而其他注釋則不顯示。
我試過比較resource.data.authorId和request.resource.data.authorId與request.auth.uid。
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /notes/{note}{
allow read: if request.auth.uid == resource.data.authorId;
}
}
}
我只希望用戶創建的注釋顯示出來,而此規則根本不顯示注釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.