diff --git a/lib/decentralised_book_index/metadata/publisher.ex b/lib/decentralised_book_index/metadata/publisher.ex index 2d2f9c3..bd0f910 100644 --- a/lib/decentralised_book_index/metadata/publisher.ex +++ b/lib/decentralised_book_index/metadata/publisher.ex @@ -9,28 +9,6 @@ defmodule DecentralisedBookIndex.Metadata.Publisher do require Ash.Query alias DecentralisedBookIndex.Metadata - policies do - bypass actor_attribute_equals(:role, :admin) do - authorize_if always() - end - - policy action_type(:read) do - authorize_if always() - end - - policy action_type(:create) do - authorize_if actor_attribute_equals(:role, :moderator) - end - - policy action_type(:update) do - authorize_if actor_attribute_equals(:role, :moderator) - end - - policy action_type(:destroy) do - authorize_if actor_attribute_equals(:role, :admin) - end - end - json_api do type "publisher" end @@ -79,6 +57,28 @@ defmodule DecentralisedBookIndex.Metadata.Publisher do end end + policies do + bypass actor_attribute_equals(:role, :admin) do + authorize_if always() + end + + policy action_type(:read) do + authorize_if always() + end + + policy action_type(:create) do + authorize_if actor_attribute_equals(:role, :moderator) + end + + policy action_type(:update) do + authorize_if actor_attribute_equals(:role, :moderator) + end + + policy action_type(:destroy) do + authorize_if actor_attribute_equals(:role, :admin) + end + end + attributes do uuid_primary_key :id, writable?: true @@ -87,7 +87,7 @@ defmodule DecentralisedBookIndex.Metadata.Publisher do public? true end - timestamps() do + timestamps do writable? true public? true end