Replies: 2 comments 3 replies
-
First of all, if you have rules in array no need to use AbilityBuilder. Just pass them to also check example app https://github.com/stalniy/casl-examples/tree/master/packages/fastify-prisma-blog you should have one set of subjects. Subject type is your app entity type. So if you have a blog app, your models or entities are: BlogPost, User, Comment, etc |
Beta Was this translation helpful? Give feedback.
-
Ok, I think I'm starting to come around. It appears that I don't even need the |
Beta Was this translation helpful? Give feedback.
-
Working from the following example...
Given that my rules are coming in from the user session I cannot hard code them. If I try to use forEach loop them I must know the model type for each.
The Docs only cover a single use case when providing an example and that use case won't work for me. Is there another example somewhere?
Another issue I am having is that I need to use CASL in my router guards and with Prisma but I am finding it difficult to share any code between the two use cases. I have to maintain two sets of subjects and I cannot figure out how to generate the Prisma rules from the same rules I used for the router guards.
Beta Was this translation helpful? Give feedback.
All reactions