Is it possible to set the security rules so that only some field could be updated based on the user role?
Consider a user attempts to edit the following document to edit:
/tasks/task1
{
"id":"task1",
"description":"anyone can edit this",
"sensitive_info":"only editor can edit this",
"very_sensitive_info":"only admin can edit this",
}
}
And here is the users collection with roles
/users/user1 { "role":"admin" }
/users/user2 { "role":"editor" }
/users/user3 { "role":"anyone" }
match /tasks/{userId} {
allow read: if true;
allow create: if true;
allow update: if <CONDITION HERE>; // <-WHAT GOES HERE?
}
How to allow the field "sensitive_info" to only be editable by user2 and user1 but not user3?