Files
docuseal/app/controllers/account_configs_controller.rb
T

47 lines
1.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class AccountConfigsController < ApplicationController
before_action :load_account_config
authorize_resource :account_config
ALLOWED_KEYS = [
AccountConfig::ALLOW_TYPED_SIGNATURE,
2023-12-21 23:29:06 +02:00
AccountConfig::FORCE_MFA,
2024-01-30 17:03:58 +02:00
AccountConfig::ALLOW_TO_RESUBMIT,
2024-10-24 12:15:32 +03:00
AccountConfig::ALLOW_TO_DECLINE_KEY,
2024-06-15 15:55:09 +03:00
AccountConfig::FORM_PREFILL_SIGNATURE_KEY,
2024-03-09 23:29:59 +02:00
AccountConfig::ESIGNING_PREFERENCE_KEY,
2024-04-15 19:58:24 +03:00
AccountConfig::FORM_WITH_CONFETTI_KEY,
2024-04-19 02:04:35 +03:00
AccountConfig::DOWNLOAD_LINKS_AUTH_KEY,
2024-04-22 21:34:55 +03:00
AccountConfig::FORCE_SSO_AUTH_KEY,
2024-07-24 20:55:35 +03:00
AccountConfig::FLATTEN_RESULT_PDF_KEY,
2024-08-06 00:19:33 +03:00
AccountConfig::WITH_SIGNATURE_ID,
2024-08-23 23:46:22 +03:00
AccountConfig::COMBINE_PDF_RESULT_KEY,
2024-11-20 01:12:26 +02:00
AccountConfig::REQUIRE_SIGNING_REASON_KEY,
AccountConfig::DOCUMENT_FILENAME_FORMAT_KEY
].freeze
2024-02-29 23:59:49 +02:00
InvalidKey = Class.new(StandardError)
def create
@account_config.update!(account_config_params)
head :ok
end
private
def load_account_config
2024-02-29 23:59:49 +02:00
raise InvalidKey unless ALLOWED_KEYS.include?(account_config_params[:key])
@account_config =
AccountConfig.find_or_initialize_by(account: current_account, key: account_config_params[:key])
end
def account_config_params
params.required(:account_config).permit!.tap do |attrs|
attrs[:value] = attrs[:value] == '1' if attrs[:value].in?(%w[1 0])
end
end
end