Ash FrameworkAF
Ash Framework3y ago
2 replies
Blibs

Policy for action stopped being called

In my User resource, I have this action:

    update :confirm_phone_number do
      alias Actions.ConfirmPhoneNumber.Changes

      accept []

      argument :code, :string, allow_nil?: false

      change Changes.VerifyCode

      change set_attribute(:confirmed_at, DateTime.utc_now())

      change Changes.SendEmail
    end


And also this policy for it:

    alias Marketplace.Accounts.User.Checks

    bypass AshAuthentication.Checks.AshAuthenticationInteraction do
      authorize_if always()
    end

    policy action(:confirm_phone_number) do
      forbid_unless Checks.NotConfirmedYet
      authorize_if always()
    end


I expect that the NotConfirmedYet policy will be called when running User.confirm_phone_number(user, %{code: "1234"}), but it isn't.

I'm pretty sure this was working before, so I'm not sure if it is a bug in the new versions of Ash (I'm using the latest 2.9.11) or something else I messed up.
Was this page helpful?