I am trying to use the accessibleBy function from @casl/mongoose like this:
const matchesAbilityRights = await database
.model("Person")
.accessibleBy(user.ability);
My ability is defined from this JSON array:
[
{
action: 'read',
subject: 'User',
conditions: { 'organizations.organization': 5e318fb83002794738039ae2 }
},
{ action: 'create', subject: 'User' },
{
subject: 'Person',
action: 'delete',
conditions: { creator: { '$in': [ 5d51518e5b84777cd6f54bcb ] } }
}
]
This error is thrown when you don't have the ability. But when you do, it works like expected.
TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
at /Users/data-api/node_modules/@casl/mongoose/dist/umd/index.js:1:852
at Function.u [as accessibleBy] (/Users/data-api/node_modules/@casl/mongoose/dist/umd/index.js:1:969)
at /Users/data-api/dist/api/person/person.js:33:18
at Generator.next (<anonymous>)
at /Users/data-api/dist/api/person/person.js:8:71
Hi
Thanks for the time to contribute this issue! The issue is fixed now and I'm currently working on another issue with types. When that is finished, I will release a patch version.
Plan to be done today, probably tomorrow
fixed in @casl/[email protected]. Thanks again!