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

Object prototype may only be an Object or null: undefined on no abiltity #287

Closed
vemundeldegard opened this issue Apr 10, 2020 · 2 comments
Labels

Comments

@vemundeldegard
Copy link

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
@stalniy stalniy added the bug label Apr 10, 2020
@stalniy
Copy link
Owner

stalniy commented Apr 10, 2020

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

@stalniy
Copy link
Owner

stalniy commented Apr 10, 2020

fixed in @casl/[email protected]. Thanks again!

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