|
|
|
@ -8,28 +8,6 @@ defmodule DecentralisedBookIndex.Metadata.AuthorRole do
|
|
|
|
|
|
|
|
|
|
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 "author_role"
|
|
|
|
|
end
|
|
|
|
@ -97,6 +75,28 @@ defmodule DecentralisedBookIndex.Metadata.AuthorRole 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, :moderator)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
attributes do
|
|
|
|
|
uuid_primary_key :id, writable?: true
|
|
|
|
|
|
|
|
|
|