feeds_controller_policy.rb 513 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 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', token: given_token)&.permissions?('knowledge_base.*')
  16. end
  17. def given_token
  18. record.params[:token]
  19. end
  20. end