How to use arguments in policies
I have a
rooms has_many members
situation in which I want to authorize joining a room if the user has its invite code, but I can't seem to make it work, even after repeatedly reading through the docs, example apps and source code.
The room resource looks like this:
The member resource authorizes everything:
This is what I get when trying to join a room: (message is too long, see attachment)
I'm not sure why it first says Successful authorization and then forbidden. I'm not sure if I'm missing something to make the argument available to the policy, or if I should be using validations instead, or something completely different.
Thanks in advance2 Replies
This is likely an oversight in the way we build expressions for policies.
You cannot reference args like that. You need to write a simple check or filter check and use that in place of an expression.
Found 3 Code results in ash:
* Ash.Policy.SimpleCheck: http://ash-hq.org/docs/module/ash/2.5.8/ash-policy-simplecheck
* Ash.Policy.Check: http://ash-hq.org/docs/module/ash/2.5.8/ash-policy-check
* type: http://ash-hq.org/docs/module/ash/2.5.8/ash-policy-check#callback-type-0