Check If Auth.id Is In Resource Data Map With Firestore.rules?
I struggle to find a way to create a rule that allow read if a user is a participant in a document.
I have a collection of documents where "participants" in each document is defined as an array of objects. I would like to allow read, when the user's auth.uid is equal to the userId attribute of one of the participant objects.
Now in my firestore.rules I would like to write something like:
if resource.data.participants.find(p => p.userId == request.auth.uid)
...but that is not possible
Is there any way to put this into a function that will do the or another way to get around it?
This type of check is currently not possible with security rules, because there is no iteration in the language, and there are no map() or filter() type functions available on list type objects.
You always welcome to file a feature request for the latter (iteration will likely never be part of the language, but list map and filter are possibilities).
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?