Skip to content
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

Checking if User Has More than one rule at a Time #237

Closed
clmorales opened this issue Nov 19, 2019 · 2 comments
Closed

Checking if User Has More than one rule at a Time #237

clmorales opened this issue Nov 19, 2019 · 2 comments
Labels

Comments

@clmorales
Copy link

How Can I check more than one rule a a time. What I want is to verify if the user has one of the rules.

The following will return true if the user has this set of rules
can('read','Post)
can('create','Post')
can('read','Task')
can('create','Task')

ability.can(['read','create'], ['Post','Task']); // true;

@stalniy
Copy link
Owner

stalniy commented Nov 19, 2019

Just call ability.can several times.

ability.can(“read”, “Task”) && ability.can(“create”, “Task”)

Casl doesn’t support arrays in arguments of ability.can because the meaning is ambiguous. Some may expect it to check by OR logic (because this is what his app needs) and others will expect AND logic

@stalniy
Copy link
Owner

stalniy commented Nov 25, 2019

Close as there is nothing to do from my side.

Thanks for trusting CASL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants