-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with allowed fields and patch action #229
Comments
Hi, Checking by fields is a separate thing. So, your permissions says: So, then you have several ways to check permissions:
|
Ah thanks a lot for the explanations. Would it make sense to, instead of only passing a single field key to the ability.can() function, also being able to pass an array? Then one could pass the return value of the permittedFieldsOf() function. |
There is no sense to pass the result of I considered passing an array of fields as a 3rd argument to ability.can but there is an issue:
I haven’t solved this issue yet, that’s why the 3rd argument is a single string |
Hi, thanks for this great package, its really a big help!
I am having problems wrapping my head around how casl handles ability checking when fields and limiting is involved. I am using mongoose.
When implementing a rule like so
then I expect casl to evaluate
ability.can('patch', {isPublic: true});
to true, because a patch is just a patch, i'm not trying to replace the dataset, just updating the specified fields.Am i thinking about this the wrong way, should there be different handling between 'patch' & 'update' ?
One workaround is to fetch the current dataset and check the ability with that instead of the new one, and afterwards always use lodash.pick to constrain the new dataset.
Another workaround would be to add
undefined
to the $in array.But those feel a little wrong. Do you have ideas on how to tackle this problem? Maybe implement different handling between update & patch operations?
Thanks!
The text was updated successfully, but these errors were encountered: