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

Check for multiple abilities in logical OR #217

Closed
rahulpsd18 opened this issue Aug 21, 2019 · 2 comments
Closed

Check for multiple abilities in logical OR #217

rahulpsd18 opened this issue Aug 21, 2019 · 2 comments
Labels

Comments

@rahulpsd18
Copy link

I can't seem to find a way to check for multiple abilities (logical OR) in the documentation:

My use case is:
Suppose there are 4 possible abilities ('A', 'B', 'C', 'D') on a resource "Product", I want a button to be visible to the user in case he has ability A or B .

I did came across "Define own aliases" in the readme which states that we can define "modify" alias as a combination of update and delete actions:

// user can modify only if he has both update and delete permission
Ability.addAlias('modify', ['update', 'delete'])

but I need an "OR" case instead of "AND".

Any help would be appreciated. Thanks!

@stalniy
Copy link
Owner

stalniy commented Aug 22, 2019

There is no support for OR logic.

Do you have suggestions how to implement it in clear way?

What you can do now:

if (ability.can(“A”, “Product”) || ability.can(“B”, “Product”)) {
  // do something 
}

@stalniy
Copy link
Owner

stalniy commented Aug 23, 2019

Close due to inactivity. Feel free to suggest and reopen the issue

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