ash/test/support/policy_field/resources/user.ex

35 lines
614 B
Elixir
Raw Normal View History

defmodule Ash.Test.Support.PolicyField.User do
2023-06-23 06:19:40 +12:00
@moduledoc false
use Ash.Resource,
data_layer: Ash.DataLayer.Ets,
authorizers: [Ash.Policy.Authorizer]
ets do
private? true
end
actions do
defaults [:create, :read, :update, :destroy]
end
attributes do
uuid_primary_key :id
attribute :role, :atom do
constraints one_of: [:user, :representative]
end
end
policies do
policy always() do
authorize_if always()
end
end
field_policies do
field_policy :role do
authorize_if actor_attribute_equals(:role, :representative)
end
end
end