I have this Firebase DB which could be changed if necessary:
The JSON of that DB is:
{
\"groups\": {
\"1\": {
\"name\": \"G1\",
What if you try nested rules for the "points" and "visits" levels:
"groups": {
"$groupId": {
".read": "root.child('userGroups').child(auth.uid).child($groupId).exists()",
".write": "root.child('userGroups').child(auth.uid).child($groupId).val() == 'admin'",
"points": {
".write": "root.child('userGroups').child(auth.uid).child($groupId).val() != 'readonly'"
},
"visits": {
".write": "root.child('userGroups').child(auth.uid).child($groupId).val() != 'readonly'"
}
}
},
"users": {
"$userId": {
".read": "auth != null",
".write": "auth != null &&
$userId === auth.uid &&
newData.val() != null"
}
},
"userGroups": {
"$userId": {
".read": "auth != null",
".write": "auth != null &&
data.child(auth.uid).val() === 'admin' &&
newData.val() != null"
}
}