The personal finance app for everyone
Fix account param safety
Rob Zolkos9aa9f9981029
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rbindex 52e05739..18d6106e 100644--- a/app/controllers/accounts_controller.rb+++ b/app/controllers/accounts_controller.rb@@ -33,8 +33,12 @@ class AccountsController < ApplicationControllerenddef account_type_class- params[:type].constantize- rescue- Account # Default to Account if type is not provided or invalid+ valid_account_types = %w[Checking CreditCard]++ if params[:type].present? && valid_account_types.include?(params[:type])+ params[:type].constantizes+ else+ Account # Default to Account if type is not provided or invalid+ endendenddiff --git a/app/models/depository.rb b/app/models/depository.rbindex 64413a49..bacbb9e6 100644--- a/app/models/depository.rb+++ b/app/models/depository.rb@@ -1,2 +1,2 @@class Depository < Account-end\ No newline at end of file+enddiff --git a/config/routes.rb b/config/routes.rbindex 0a4af242..3edbdf2a 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -6,9 +6,9 @@ Rails.application.routes.draw doresources :accounts- scope 'accounts/new' do- scope 'bank' do- get '', to: 'accounts#new_bank', as: 'new_bank'+ scope "accounts/new" do+ scope "bank" do+ get "", to: "accounts#new_bank", as: "new_bank"endend