6
嘗試寫入Firestore時出現錯誤。在訪問規則中使用字段寫入Firestore時缺少權限或權限不足
我正在嘗試爲我的安全規則使用包含用戶uid的字段。
service cloud.firestore {
match /databases/{database}/documents {
match /messages/{document=**} {
allow read: if resource.data.user_uid == request.auth.uid;
allow write: if resource.data.user_uid == request.auth.uid;
}
}
}
如果我在公司的FireStore數據庫具有數據,所讀取的規則工作正常 - 但是當我試圖寫我得到:Error: Missing or insufficient permissions.
有什麼是我做錯了這個寫入規則?
P.S.如果我更改了規則,這一點,我能寫我的數據庫 - 但是這不是我的目的,足夠安全:
match /messages/{document=**} {
allow read: if resource.data.user_uid == request.auth.uid;
allow write: if request.auth != null;
}
感謝那些工作。 Firebase文檔需要更新,他們只是舉例閱讀,他們也應該舉例寫作...... –
@LeoFarmer這裏有一個關於不同安全規則的相當廣泛的文檔:https://firebase.google.com/文檔/公司的FireStore /安全性/安全數據 – Scarygami