Files

35 lines
899 B
Ruby
Raw Permalink Normal View History

2023-05-21 17:59:36 +03:00
# frozen_string_literal: true
class StorageSettingsController < ApplicationController
before_action :load_encrypted_config
2023-09-17 00:45:57 +03:00
authorize_resource :encrypted_config, only: :index
authorize_resource :encrypted_config, parent: false, only: :create
2023-05-21 17:59:36 +03:00
def index; end
def create
if @encrypted_config.update(storage_configs)
LoadActiveStorageConfigs.reload
2024-09-18 19:47:47 +03:00
redirect_to settings_storage_index_path, notice: I18n.t('changes_have_been_saved')
2023-05-21 17:59:36 +03:00
else
2025-08-14 09:25:35 +03:00
render :index, status: :unprocessable_content
2023-05-21 17:59:36 +03:00
end
end
private
def load_encrypted_config
@encrypted_config =
EncryptedConfig.find_or_initialize_by(account: current_account, key: EncryptedConfig::FILES_STORAGE_KEY)
end
def storage_configs
params.require(:encrypted_config).permit(value: {}).tap do |e|
e[:value].compact_blank!
e.dig(:value, :configs)&.compact_blank!
end
end
end