I need help in creating some Firestore security rules to work with queries in my code. So I have tried using HashMap as below, 'sharedWith' is a hashmap field in my document:
...
sharedWith
abc@gmail.com : true
zzz@gmail.com : true
...
My security rule I tried setting up as below:
allow read: if isSignedIn() && resource.data.sharedWith[request.auth.token.email]=="true"
What I am expecting to happen is when user 'zzz' is logged in, that user should be able to read this document (which is created by some other user)
My query is as follows:
db.collection("Sites")
.whereEqualTo("sharedWith."+"zzz.@gmail.com",true)
.get()
.addOnSuccessListener { result -> ...
Where am I going wrong please?
Error I am getting is as folows:
Listen for Query(Sites where sharedWith.
zzz@gmail
.com == true order by name) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}