I'm trying to create an application which allows users to collaborate on lists. Every user needs to be invited in order to be able to work on the list.
I structured my data like that (loosely based on this blog post). Also this structure can be changed if needed.
list
list_1:
users:
owner:
owner@company.com: true
shared:
user@company.com: true
user2@company.com: true
id
name
items:
item_1:
id:
name:
...
What I'm trying to achieve: Everyone should be able to create lists. They creator then becomes the owner of the created list. Only the owner and users in the "shared" document should be able to read and write to this list.
I guess that the permission settings should look something like this. But this isn't working:
service cloud.firestore {
match /databases/{database}/documents {
match /lists/{listId}/{anything=**} {
allow read, write: if !exists(resource.data.users.owner) ||
resource.data.users.owner == request.auth.token.email ||
request.auth.token.email in resource.data.users.shared
}
}
}