Ash FrameworkAF
Ash Framework7mo ago
15 replies
joseph

Can I pass an argument to a custom policy check

I have the following resources: publisher, book, chapter, user, permissions.

My relationships look like the following:
Users are given permissions to a publisher. These permissions are an array of arbitrary strings.

Books are directly related to a publisher, and chapter belong to the book directly, but not the publisher.

Problem:
I want to check if a user has the correct permissions for the given publisher that's passed in as an argument for the changesets for both the book and chapter resources. I thought I could do something along the lines of authorize_if expr(has_create_permissions(actor, publisher, permissions)) but I'm having trouble figuring out where I should be defining the has_create_permissions function.

Is this something I can (or even should) do?
Was this page helpful?