external_credentials_controller_policy.rb 487 B

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