This is my DB-Structure:
users (collection) -> user-docs (uid) -> wishlists (collection) -> wishlist-docs -> wünsche -> wünsche-docs
A user-document has the field username which should be readable for everyone, also not authorized users. Other then that all the docs and fields should only be readable if the user is authorized.
A wünsche-document has a field isReservedFrom which should be writable for every user who is authorized. For all the other fields/documents users can only write their own documents.
Right now this is what I have:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read;
allow write: if request.auth != null;
}
}
}
This is not very secure and not exactly what I would like to have but I don't know how I should change it for my exact purpose. Happy for every help!
If anything is unclear just let me know!
Update
This is what I tried:
Everyone who is authorized shuold be able to write all docs and read. Only users shuold be readable for everyone. But I am messing something up with the syntax here...
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow write: if request.auth != null;
}
match /{users} {
allow read;
}
match /{users}/documents/{allSubcollections=**} {
allow read: if request.auth != null
}
}
}