Imagine I want to create an app that allows users to manage a shopping list. A user should be able to share his shopping list with other users, but users that were not 'invited' should not have access to this data.
If I want to implement this without sharing data, I can protect the user data pretty easily:
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId}/list {
allow read, update, delete: if request.auth != null && request.auth.uid == userId;
allow create: if request.auth != null;
}
}
}
But how can I make sure that 'invited' users are also able to read and write to these documents?
The data will be stored as follows:
- Collection: Lists
- Subcollection: Items
The List document will probably need to keep track of which users are allowed to add or remove Items.