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
+3 -1
View File
@@ -8,6 +8,8 @@ class UserConfigsController < ApplicationController
UserConfig::RECEIVE_COMPLETED_EMAIL
].freeze
InvalidKey = Class.new(StandardError)
def create
@user_config.update!(user_config_params)
@@ -17,7 +19,7 @@ class UserConfigsController < ApplicationController
private
def load_user_config
return head :not_found unless ALLOWED_KEYS.include?(user_config_params[:key])
raise InvalidKey unless ALLOWED_KEYS.include?(user_config_params[:key])
@user_config =
UserConfig.find_or_initialize_by(user: current_user, key: user_config_params[:key])