You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be handy if the AbilityBuilder supported the constructor function in lieu of the subject name when creating rules with can. After all, it already has the subjectName option passed in.
For example:
import { AbilityBuilder } from '@casl/ability'
import Post from './post'
function defineAbilitiesFor(user) {
return AbilityBuilder.define((can, cannot) => {
if (user.isAdmin()) {
can('manage', Post)
} else {
can('read', Post)
}
})
}
I am happy to submit a pull request with this feature.
The text was updated successfully, but these errors were encountered:
I’m ok with that. But you need to make sure that subject field in resulting rules produced by DSL is a string.
Because Ability creates an index (plain object) for that rules in order to find them quickly. I still don’t want to use Map Because this will require to add polyfill on front end side
It would be handy if the AbilityBuilder supported the constructor function in lieu of the subject name when creating rules with
can
. After all, it already has thesubjectName
option passed in.For example:
I am happy to submit a pull request with this feature.
The text was updated successfully, but these errors were encountered: