policy action([...]) do forbid_if MarketsChecks.NotConfirmedYet forbid_unless MarketsChecks.IsInvestor authorize_if always() end
policy action([...]) do forbid_if MarketsChecks.NotConfirmedYet forbid_unless MarketsChecks.IsInvestor authorize_if always() end
As you can see, the second policy checks if the actor is an investor and forbids access if it is not.
Now I want to change that policy a little bit, I want to allow it not only if it is an investor, but also if it is an agent.
I could just create an
IsInvestorOrAgent
IsInvestorOrAgent
SimpleCheck
SimpleCheck
, but I would prefer to just create an
IsAgent
IsAgent
and use it inside an expression with both checks, something like this:
policy action([...]) do forbid_if MarketsChecks.NotConfirmedYet forbid_unless expr(MarketsChecks.IsInvestor or MarketsChecks.IsAgent) authorize_if always() end
policy action([...]) do forbid_if MarketsChecks.NotConfirmedYet forbid_unless expr(MarketsChecks.IsInvestor or MarketsChecks.IsAgent) authorize_if always() end
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.