我试图在Firestore规则的帮助下建立以下场景。
如何让用户访问产品'没有认证的集合,但其他集合与认证?我已经尝试过如下规则,但它不起作用。
service cloud.firestore {
match /databases/{database}/documents {
// All should be able to access products collection
match /products {
allow read;
}
// All other collection should only be accessed if user is authenticated.
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
答案 0 :(得分:0)
这样的事情会起作用:
service cloud.firestore {
match /databases/{database}/documents {
// All should be able to access products collection
match /products/{allProducts=**} {
allow read;
}
// All other collection should only be accessed if user is authenticated.
match /{notProducts}/{allNotProducts=**} {
allow read: if notProducts != "products"
&& request.auth != null;
}
}
}