I'm trying to make new post objects readable only by users that exist in the 'members' dictionary stored in each post. I keep getting "7:17: Invalid == expression: left operand is not a number, boolean, string, or null." on the .read rule:
{
"rules": {
"posts" : {
".write":true,
"$post" : {
".read": "data.child('members').child(auth.uid) == true"
}
}
}
}
I pass the 'uid' parameter in the token I generate per: https://www.firebase.com/docs/security/custom-login.html
The purpose is to only allow posts to be read by users that exist in its member array. I can't find any examples about accessing nested data in the firebase documentation, google groups, or google searches :-(
Is this allowed/possible?
You need to add .val() after .child() in order to get the value out. :-) Try:
".read": "data.child('members').child(auth.uid).val() == true"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With