taskbar_controller_policy.rb 657 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. def init?
  19. true
  20. end
  21. private
  22. def own?
  23. taskbar = Taskbar.find(record.params[:id])
  24. return true if taskbar.user_id == user.id
  25. # current implementation requires this exception type
  26. # should be replaced by unified way
  27. not_authorized Exceptions::UnprocessableEntity.new __('Not allowed to access this task.')
  28. end
  29. end