Cloud Stack Ninja

I'm building a chat app with Firestore and each chat room has a map of participants like so:

enter image description here

The keys are the corresponding UIDs of the users. I want to use this map to decide which user can access a chat. In my security rules, I currently check if the logged-in user's UID exists in this map to allow read and write access:

allow read, write: if request.auth.uid in resource.data.participants

But this only checks if the user is in this map, not if the value is actually true. I want to check that as well.

What I basically want is something like this:

allow read, write: if resource.data.participants.request.auth.uid == true

But this does not actually work. How do I use the current user's UID as the key in a map check?



Read more here: https://stackoverflow.com/questions/64407073/use-uid-as-map-key-in-firebase-security-rules

Content Attribution

This content was originally published by Florian Walther at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: