mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Bring strong parameters code from spree to payment_methods_controller
This code comes from spree commit fbc2d150f6
This commit is contained in:
@@ -15,7 +15,7 @@ module Spree
|
||||
@payment_method = params[:payment_method].
|
||||
delete(:type).
|
||||
constantize.
|
||||
new(params[:payment_method])
|
||||
new(payment_method_params)
|
||||
@object = @payment_method
|
||||
|
||||
invoke_callbacks(:create, :before)
|
||||
@@ -40,8 +40,8 @@ module Spree
|
||||
@payment_method = PaymentMethod.find(params[:id])
|
||||
end
|
||||
|
||||
payment_method_params = params[ActiveModel::Naming.param_key(@payment_method)] || {}
|
||||
attributes = params[:payment_method].merge(payment_method_params)
|
||||
update_params = params[ActiveModel::Naming.param_key(@payment_method)] || {}
|
||||
attributes = payment_method_params.merge(update_params)
|
||||
attributes.each do |k, _v|
|
||||
if k.include?("password") && attributes[k].blank?
|
||||
attributes.delete(k)
|
||||
@@ -100,6 +100,10 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def payment_method_params
|
||||
params.require(:payment_method).permit!
|
||||
end
|
||||
|
||||
def force_environment
|
||||
params[:payment_method][:environment] = Rails.env unless spree_current_user.admin?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user