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

34 lines
595 B
Elixir
Raw Normal View History

defmodule Ash.Test.Support.PolicyField.User do
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