external_credentials_controller_policy.rb 564 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::ExternalCredentialsControllerPolicy < Controllers::ApplicationControllerPolicy
  3. permit! :index, to: 'admin'
  4. default_permit! -> { "admin.channel_#{provider_name}" }
  5. private
  6. def provider_name
  7. @provider_name ||= begin
  8. if record.params[:id].present? && ExternalCredential.exists?(record.params[:id])
  9. ExternalCredential.find(record.params[:id]).name
  10. else
  11. record.params[:provider] || record.params[:name]
  12. end
  13. end
  14. end
  15. end