Skip to content

Checking Multiple Subjects or Actions in a Single casl-react Can Check #921

Closed Answered by serhiistotskyi
nbibler asked this question in Q&A
Discussion options

You must be logged in to vote

Can you use use useAbility hook instead? if so, then you can just do ability.can('edit', 'User') || ability.can('edit', 'Post')

Your expectations is that ability.can('edit', ['User', 'Post') should return true if at least one subject type can be edited but somebody else may expect that both should be editable. This complicates types definitions. Then somebody else will request feature like can(['edit', 'create'], ['Post', 'User']) afterwards can(['edit', 'create'], ['Post', 'User'], ['status', 'author'])

This feature was requested many times and once I even tried to work on it but as far as I remember it quickly caused headache :)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nbibler
Comment options

Answer selected by nbibler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants