sergey-telpuk / nestjs-rbac

Awesome RBAC for NestJs
Other
421 stars 36 forks source link

Async filters #62

Closed vshjxyz closed 3 years ago

vshjxyz commented 3 years ago

Hello and thank you for the work on this library. I wondered if it's possible to support asynchronous filters (mainly the can function) since being injectable they already support using services internally - I wonder if you're keen to accept a PR for this change

sergey-telpuk commented 3 years ago

@vshjxyz Hello! Sure, I'm ready to accept PR. BTW it's possible to add async filter.

vshjxyz commented 3 years ago

@sergey-telpuk thanks for the quick response, I'll try to find some time asap to do these changes, although if you're saying it's possible to add async fliters I wonder how - it seems to me that the can function https://github.com/sergey-telpuk/nestjs-rbac/blob/master/src/role/role.rbac.ts#L17 here is not supporting promises/async/await. The interface for filters also does not support having the can function async https://github.com/sergey-telpuk/nestjs-rbac/blob/master/src/permissions/interfaces/filter.permission.interface.ts 🤔

sergey-telpuk commented 3 years ago

@vshjxyz I think we can add asyncFilter property