Attempting to use the CASL ability conditions for a specific subject and I can't get the id checks to work

185 Views Asked by At

I'm attempting to use the CASL ability conditions for a specific subject and I can't get the id checks to work. I need to setup an ability the can be used on a set of ids. Then in the UI ability check check an id of an object to see if it should be rendered. Does anyone have a React TS example?

Ability setup:

can(['read', 'create', 'edit', 'delete'], 'Project', { projectIds: [1, 2, 3] });

Ability check:

ability.can("read", { type: 'Project', projectIds: [ project.id ] })

Thanks.

Expecting true when the project.id is in the list.

0

There are 0 best solutions below