feeds_controller_policy.rb 512 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::KnowledgeBase::FeedsControllerPolicy < Controllers::ApplicationControllerPolicy
  3. def root?
  4. access?
  5. end
  6. def category?
  7. access?
  8. end
  9. def user_required?
  10. false
  11. end
  12. private
  13. def access?
  14. user&.permissions?('knowledge_base.*') ||
  15. Token.check(action: 'KnowledgeBaseFeed', name: given_token)&.permissions?('knowledge_base.*')
  16. end
  17. def given_token
  18. record.params[:token]
  19. end
  20. end