My firebase database rule is like the following:
{
"rules": {
"users": {
"$uid": {
".read": "auth != null || root.child('users').child(auth.uid).child('role').val() == 'teacher'",
".write": "auth != null || root.child('users').child(auth.uid).child('role').val() == 'teacher'"
}
}
}
}
My goal is the following:
- Every user can read/write their OWN data only.
- Only users with the value 'teacher' defined in their corresponding child named 'role' can read/write EVERY other users' data.
How can I achieve this rule setting?