taskbar_controller_policy.rb 571 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::TaskbarControllerPolicy < Controllers::ApplicationControllerPolicy
  3. def show?
  4. own?
  5. end
  6. def update?
  7. own?
  8. end
  9. def destroy?
  10. own?
  11. end
  12. private
  13. def own?
  14. taskbar = Taskbar.find(record.params[:id])
  15. return true if taskbar.user_id == user.id
  16. # current implementation requires this exception type
  17. # should be replaced by unified way
  18. not_authorized Exceptions::UnprocessableEntity.new __('Not allowed to access this task.')
  19. end
  20. end