getjerry/nest-casl

Cannot read properties of undefined (reading 'includes')

Closed this issue ยท 2 comments

I don't know why this happens, what i am trying to do is to simply add the AccessGuard and UseAbility Hook example working. it seems the error comes from the UseAbility.

ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'includes') TypeError: Cannot read properties of undefined (reading 'includes') at AccessService.canActivateAbility (D:\github.com\qribtech\qrib_backend\node_modules\nest-casl\src\access.service.ts:74:37) at AccessGuard.canActivate (D:\github.com\qribtech\qrib_backend\node_modules\nest-casl\src\access.guard.ts:30:37) at processTicksAndRejections (node:internal/process/task_queues:96:5) at GuardsConsumer.tryActivate (D:\github.com\qribtech\qrib_backend\node_modules\@nestjs\core\guards\guards-consumer.js:16:17) at canActivateFn (D:\github.com\qribtech\qrib_backend\node_modules\@nestjs\core\router\router-execution-context.js:134:33) at D:\github.com\qribtech\qrib_backend\node_modules\@nestjs\core\router\router-execution-context.js:42:31 at D:\github.com\qribtech\qrib_backend\node_modules\@nestjs\core\router\router-proxy.js:9:17

Looks like your user have roles undefined. In most cases this is a mistake, but I can see legit cases for user without roles, so I've fixed this error for you.

๐ŸŽ‰ This issue has been resolved in version 1.6.16 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€