taskbar_controller_policy.rb 629 B

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