Skip to content

Commit fa9226d

Browse files
committed
Update README.md
Update database rules (should let config collection accessible for read)
1 parent a76542f commit fa9226d

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,19 @@ rules_version = '2';
175175
service cloud.firestore {
176176
match /databases/{database}/documents {
177177
match /{collection}/{document}/{path=**} {
178-
allow read: if isPublic(collection, document) || isAdmin();
179-
allow write: if registrationEnabled(collection) || isAdmin() || (isEditor() && isPublic(collection, document));
178+
allow read: if canRead(collection, document);
179+
allow write: if canWrite(collection, document);
180180
}
181-
function isPublic(collection, document) {
182-
return collection != 'config' && (collection != 'users' || isOwner(document));
181+
function canRead(collection, document) {
182+
return isAccessible(collection, document) || isAdmin();
183+
}
184+
function canWrite(collection, document) {
185+
return registrationEnabled(collection) || isAdmin() || (
186+
isEditor() && collection != 'config' && isAccessible(collection, document)
187+
);
188+
}
189+
function isAccessible(collection, document) {
190+
return collection != 'users' || isOwner(document);
183191
}
184192
function isSignedIn() {
185193
return request.auth != null;

0 commit comments

Comments
 (0)