omar-dulaimi / trpc-shield

🛡 A tRPC tool to ease the creation of permission layer.
MIT License
402 stars 10 forks source link

fix: throw the Error or string if one is returned by a rule #12

Closed lottamus closed 1 year ago

lottamus commented 1 year ago

Currently the middleware is only checking truthiness on the response from the resolver. So if you return a string or Error, it will pass the rule instead of failing.

https://github.com/omar-dulaimi/trpc-shield/blob/d8bd1f3151dd08486ffcfbadac1605c39c5af807/src/rules.ts#L26-L29

This PR handles throwing the Error returned from the resolver.

omar-dulaimi commented 1 year ago

LGTM!

omar-dulaimi commented 1 year ago

Thank you for the PR. Released in https://github.com/omar-dulaimi/trpc-shield/releases/tag/0.4.1