-
Hi, I have this rule for updating an Account can(Action.Update, Account, ['name'], {
id: {
$in: accountIds,
},
}); And it works as it should, for example ability.can(Action.Update, account, 'name') // returns true
ability.can(Action.Update, account, 'region') // returns false What bothers me is when somebody does this: ability.can(Action.Update, account) // returns true so I added this rule cannot(Action.Update, Account).because('Field must be specified'); and I thought that now the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
What you want is flag/claim based permission checks. Let’s map what you did in casl to real world If you have access to a room inside some building, do you then have access to the building itself? Yes because room is part of building and there is no way to enter room without accessing building. This is how casl was designed and how it works. Name is an attribute of Account, this is part of an Account, if you can update part of an Account it means you can update Account. Because when you update part of a whole, you update this whole. I believe it’s logical If this is not desired, you have 2 options:
|
Beta Was this translation helpful? Give feedback.
What you want is flag/claim based permission checks. Let’s map what you did in casl to real world
If you have access to a room inside some building, do you then have access to the building itself? Yes because room is part of building and there is no way to enter room without accessing building.
This is how casl was designed and how it works.
Name is an attribute of Account, this is part of an Account, if you can update part of an Account it means you can update Account. Because when you update part of a whole, you update this whole. I believe it’s logical
If this is not desired, you have 2 options: