stalniy / casl

CASL is an isomorphic authorization JavaScript library which restricts what resources a given user is allowed to access
https://casl.js.org/
MIT License
5.74k stars 257 forks source link

bug: subject helper error #912

Closed Nishchit14 closed 1 month ago

Nishchit14 commented 1 month ago

Describe the bug When I use subject helper multiple time in the same function to check multiple permission then it's showing error

ability.can('create', subject('folder', {}));
ability.can('read', subject('chat',{}));

Error

Error: Trying to cast object to subject type chat but previously it was casted to folder

CASL Version

@casl/ability - v6.7.1

Environment: Nodejs version v21

stalniy commented 1 month ago

Cannot reproduce, If you look into code this error is thrown only if you try to change the type of previously used object - https://github.com/stalniy/casl/blob/master/packages/casl-ability/src/utils.ts#L25

stalniy commented 1 month ago

close as I stale. Feel free to comment and provide additional details