policies do
bypass action_type(:create) do
authorize_if always()
end
bypass action(:join) do
authorize_if expr(invite_code == ^arg(:invite_code))
end
policy always() do
authorize_if expr(exists(members, id == ^actor(:id)))
end
end
...
actions do
defaults [:update, :destroy]
read :read do
primary? true
end
create :create do
accept [:name]
end
update :join do
argument :name, :string do
allow_nil? false
end
argument :invite_code, :uuid do
allow_nil? false
end
change manage_relationship :name, :members,
value_is_key: :name,
type: :create
end
end
policies do
bypass action_type(:create) do
authorize_if always()
end
bypass action(:join) do
authorize_if expr(invite_code == ^arg(:invite_code))
end
policy always() do
authorize_if expr(exists(members, id == ^actor(:id)))
end
end
...
actions do
defaults [:update, :destroy]
read :read do
primary? true
end
create :create do
accept [:name]
end
update :join do
argument :name, :string do
allow_nil? false
end
argument :invite_code, :uuid do
allow_nil? false
end
change manage_relationship :name, :members,
value_is_key: :name,
type: :create
end
end