Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule Author do
- use Ash.Resource, name: "authors", type: "author"
- use Ash.DataLayer.Ets, private?: true
- actions do
- read :default
- create :default,
- authorization_steps: [
- authorize_if: user_attribute(:admin, true),
- authorize_if: user_attribute(:manager, true)
- ]
- end
- attributes do
- attribute :name, :string, authorization_steps: false
- attribute :state, :string
- authorization_steps: [
- authorize_if: user_attribute(:admin, true),
- forbid_if: setting_to("admin_only_state"),
- authorize_if: always()
- ]
- attribute :self_manager, :boolean
- authorization_steps: [
- authorize_if: user_attribute(:admin, true)
- ]
- attribute :fired, :boolean
- authorization_steps: [
- authorize_if: user_attribute(:admin, true),
- forbid_if: attribute_equals(:self_manager, true),
- authorize_if: always()
- ]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement