webhook_policy.rb 654 B

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. class WebhookPolicy < ApplicationPolicy
  3. def index?
  4. role.can?(:manage_webhooks)
  5. end
  6. def create?
  7. role.can?(:manage_webhooks)
  8. end
  9. def show?
  10. role.can?(:manage_webhooks)
  11. end
  12. def update?
  13. role.can?(:manage_webhooks) && record.required_permissions.all? { |permission| role.can?(permission) }
  14. end
  15. def enable?
  16. role.can?(:manage_webhooks)
  17. end
  18. def disable?
  19. role.can?(:manage_webhooks)
  20. end
  21. def rotate_secret?
  22. role.can?(:manage_webhooks)
  23. end
  24. def destroy?
  25. role.can?(:manage_webhooks) && record.required_permissions.all? { |permission| role.can?(permission) }
  26. end
  27. end