organization_policy.rb 542 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class OrganizationPolicy < ApplicationPolicy
  3. def show?
  4. return true if accessible?
  5. return customer_field_scope if user.organization_id?(record.id)
  6. false
  7. end
  8. def update?
  9. return true if accessible?
  10. false
  11. end
  12. private
  13. def accessible?
  14. user.permissions?(['admin.organization', 'ticket.agent'])
  15. end
  16. def customer_field_scope
  17. @customer_field_scope ||= ApplicationPolicy::FieldScope.new(allow: %i[id name active])
  18. end
  19. end