Ash FrameworkAF
Ash Frameworkβ€’5mo agoβ€’
39 replies
Vic

Ash policies breakdown not showing help_text

I have this policy (check if the role theyre trying to change the user into is super_admin and if theyre not a super_admin themselves block them)
policy action(:change_role) do
      forbid_if expr(
                  args(:role) == :super_admin &&
                    ^actor(:role) != :super_admin
                )


it fails with this error
dmin"}}
[error] Jnb.Accounts.User.change_role


Policy Breakdown
  user: %{id: "dc6dab27-b724-4f6b-b118-78e47c0ad1fc"}

  Policy | πŸ”Ž:

    condition: action == :change_role

    forbid if: args(:role) == :super_admin && :super_admin != :super_admin | ? | πŸ”Ž

SAT Solver statement:

 "action == :change_role" and
  (("action == :change_role" and false) or not "action == :change_role")

and this is my dev.exs relevant config
config :ash,
  policies: [
    log_policy_breakdowns: :error,
    log_successful_policy_breakdowns: :info,
    help_text?: true
  ]

Why am I not seing the helper text? Also why can't I access the roles args? or why is my policy not evaluated? This is on a normal liveview, the user IS super_admin, and I have commented out all other policies, (except the AshAuthentication) so I am not sure why its returning forbidden, the user I am trying to modify as a test is myself, also, according to docs I should use ^arg() but whenever I try that I get that its not defined, am I missing an import? aside from the config like this in the ash.Resource
   data_layer: AshPostgres.DataLayer,
    authorizers: [Ash.Policy.Authorizer],
    extensions: [AshAuthentication]
Solution
fixed
Was this page helpful?