1 回答

TA貢獻1803條經驗 獲得超6個贊
您的問題似乎來自您閱讀sub-collections 中的文檔這一事實。
讓我們以集合為例topsection。您有如下安全規則:
match /topsection/{id} {
allow read: if true;
allow write: if request.auth.uid != null;
}
但是您查詢文檔如下:
getTopSectionMain() {
return this.firestore.collection('topsection').doc('content').collection('main').snaps hotChanges();
}
這意味著您查詢集合中文檔的main子集合的content文檔topsection。
如文檔中所述:“安全規則僅適用于匹配的路徑,因此在(父)集合上定義的訪問控制不適用于(子)子集合?!?/p>
您需要通過添加遞歸通配符來調整規則
match /topsection/{document=**} {
allow read: if true;
allow write: if request.auth.uid != null;
}
或指定每個子集合,如:
match /topsection/{id} {
match /main/{id} {
allow read: if true;
allow write: if request.auth.uid != null;
}
}
由于您沒有使用通配符來聲明頂級集合的安全規則,因此您最好使用第二個選項。
添加回答
舉報