validate account config keys

This commit is contained in:
Pete Matsyburka
2024-02-29 23:59:49 +02:00
parent 8432bec3d6
commit c743cc689d
4 changed files with 32 additions and 9 deletions
@@ -11,6 +11,8 @@ class AccountConfigsController < ApplicationController
AccountConfig::ESIGNING_PREFERENCE_KEY
].freeze
InvalidKey = Class.new(StandardError)
def create
@account_config.update!(account_config_params)
@@ -20,7 +22,7 @@ class AccountConfigsController < ApplicationController
private
def load_account_config
return head :not_found unless ALLOWED_KEYS.include?(account_config_params[:key])
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])