Parsed frame accessible from only params

This commit is contained in:
Martin Lensment 2015-01-16 16:21:31 +02:00
parent fe74c0bd64
commit 3ed2cddad4
4 changed files with 13 additions and 17 deletions

View file

@ -24,10 +24,6 @@ module Epp::Common
@params_hash ||= Hash.from_xml(params[:frame]).with_indifferent_access
end
def parsed_frame
@parsed_frame ||= Nokogiri::XML(params[:frame]).remove_namespaces!
end
def epp_session
cookie = env['rack.request.cookie_hash'] || {}
EppSession.find_or_initialize_by(session_id: cookie['session'])
@ -66,7 +62,7 @@ module Epp::Common
def epp_request_valid?(*selectors)
selectors.each do |selector|
el = parsed_frame.css(selector).first
el = params[:parsed_frame].css(selector).first
epp_errors << {
code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: el.try(:name) || selector)

View file

@ -89,9 +89,9 @@ class Epp::ContactsController < ApplicationController
end
def update_attrs_present?
return true if parsed_frame.css('add').present?
return true if parsed_frame.css('rem').present?
return true if parsed_frame.css('chg').present?
return true if params[:parsed_frame].css('add').present?
return true if params[:parsed_frame].css('rem').present?
return true if params[:parsed_frame].css('chg').present?
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: 'add, rem or chg') }
end
@ -176,13 +176,13 @@ class Epp::ContactsController < ApplicationController
Address.extract_attributes((prms.try(:[], :postalInfo) || []))
)
contact_hash[:disclosure_attributes] =
ContactDisclosure.extract_attributes(parsed_frame)
ContactDisclosure.extract_attributes(params[:parsed_frame])
contact_hash
end
def ident_type
result = parsed_frame.css('ident').first.try(:attributes).try(:[], 'type').try(:value)
result = params[:parsed_frame].css('ident').first.try(:attributes).try(:[], 'type').try(:value)
return nil unless result
Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) }

View file

@ -192,8 +192,8 @@ class Epp::DomainsController < ApplicationController
def domain_transfer_params
res = {}
res[:pw] = parsed_frame.css('pw').first.try(:text)
res[:action] = parsed_frame.css('transfer').first[:op]
res[:pw] = params[:parsed_frame].css('pw').first.try(:text)
res[:action] = params[:parsed_frame].css('transfer').first[:op]
res[:current_user] = current_epp_user
res
end

View file

@ -2,8 +2,8 @@ class Epp::PollsController < ApplicationController
include Epp::Common
def poll
req_poll if parsed_frame.css('poll').first['op'] == 'req'
ack_poll if parsed_frame.css('poll').first['op'] == 'ack'
req_poll if params[:parsed_frame].css('poll').first['op'] == 'req'
ack_poll if params[:parsed_frame].css('poll').first['op'] == 'ack'
end
def req_poll
@ -22,13 +22,13 @@ class Epp::PollsController < ApplicationController
end
def ack_poll
@message = current_epp_user.queued_messages.find_by(id: parsed_frame.css('poll').first['msgID'])
@message = current_epp_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
unless @message
epp_errors << {
code: '2303',
msg: I18n.t('message_was_not_found'),
value: { obj: 'msgID', val: parsed_frame.css('poll').first['msgID'] }
value: { obj: 'msgID', val: params[:parsed_frame].css('poll').first['msgID'] }
}
handle_errors and return
end
@ -40,7 +40,7 @@ class Epp::PollsController < ApplicationController
private
def validate_poll
op = parsed_frame.css('poll').first[:op]
op = params[:parsed_frame].css('poll').first[:op]
return true if %w(ack req).include?(op)
epp_errors << { code: '2306', msg: I18n.t('errors.messages.attribute_op_is_invalid') }
false