mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Parsed frame accessible from only params
This commit is contained in:
parent
fe74c0bd64
commit
3ed2cddad4
4 changed files with 13 additions and 17 deletions
|
@ -24,10 +24,6 @@ module Epp::Common
|
||||||
@params_hash ||= Hash.from_xml(params[:frame]).with_indifferent_access
|
@params_hash ||= Hash.from_xml(params[:frame]).with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
def parsed_frame
|
|
||||||
@parsed_frame ||= Nokogiri::XML(params[:frame]).remove_namespaces!
|
|
||||||
end
|
|
||||||
|
|
||||||
def epp_session
|
def epp_session
|
||||||
cookie = env['rack.request.cookie_hash'] || {}
|
cookie = env['rack.request.cookie_hash'] || {}
|
||||||
EppSession.find_or_initialize_by(session_id: cookie['session'])
|
EppSession.find_or_initialize_by(session_id: cookie['session'])
|
||||||
|
@ -66,7 +62,7 @@ module Epp::Common
|
||||||
|
|
||||||
def epp_request_valid?(*selectors)
|
def epp_request_valid?(*selectors)
|
||||||
selectors.each do |selector|
|
selectors.each do |selector|
|
||||||
el = parsed_frame.css(selector).first
|
el = params[:parsed_frame].css(selector).first
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: '2003',
|
code: '2003',
|
||||||
msg: I18n.t('errors.messages.required_parameter_missing', key: el.try(:name) || selector)
|
msg: I18n.t('errors.messages.required_parameter_missing', key: el.try(:name) || selector)
|
||||||
|
|
|
@ -89,9 +89,9 @@ class Epp::ContactsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_attrs_present?
|
def update_attrs_present?
|
||||||
return true if parsed_frame.css('add').present?
|
return true if params[:parsed_frame].css('add').present?
|
||||||
return true if parsed_frame.css('rem').present?
|
return true if params[:parsed_frame].css('rem').present?
|
||||||
return true if parsed_frame.css('chg').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') }
|
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: 'add, rem or chg') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -176,13 +176,13 @@ class Epp::ContactsController < ApplicationController
|
||||||
Address.extract_attributes((prms.try(:[], :postalInfo) || []))
|
Address.extract_attributes((prms.try(:[], :postalInfo) || []))
|
||||||
)
|
)
|
||||||
contact_hash[:disclosure_attributes] =
|
contact_hash[:disclosure_attributes] =
|
||||||
ContactDisclosure.extract_attributes(parsed_frame)
|
ContactDisclosure.extract_attributes(params[:parsed_frame])
|
||||||
|
|
||||||
contact_hash
|
contact_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def ident_type
|
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
|
return nil unless result
|
||||||
|
|
||||||
Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) }
|
Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) }
|
||||||
|
|
|
@ -192,8 +192,8 @@ class Epp::DomainsController < ApplicationController
|
||||||
|
|
||||||
def domain_transfer_params
|
def domain_transfer_params
|
||||||
res = {}
|
res = {}
|
||||||
res[:pw] = parsed_frame.css('pw').first.try(:text)
|
res[:pw] = params[:parsed_frame].css('pw').first.try(:text)
|
||||||
res[:action] = parsed_frame.css('transfer').first[:op]
|
res[:action] = params[:parsed_frame].css('transfer').first[:op]
|
||||||
res[:current_user] = current_epp_user
|
res[:current_user] = current_epp_user
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,8 @@ class Epp::PollsController < ApplicationController
|
||||||
include Epp::Common
|
include Epp::Common
|
||||||
|
|
||||||
def poll
|
def poll
|
||||||
req_poll if parsed_frame.css('poll').first['op'] == 'req'
|
req_poll if params[:parsed_frame].css('poll').first['op'] == 'req'
|
||||||
ack_poll if parsed_frame.css('poll').first['op'] == 'ack'
|
ack_poll if params[:parsed_frame].css('poll').first['op'] == 'ack'
|
||||||
end
|
end
|
||||||
|
|
||||||
def req_poll
|
def req_poll
|
||||||
|
@ -22,13 +22,13 @@ class Epp::PollsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def ack_poll
|
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
|
unless @message
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: '2303',
|
code: '2303',
|
||||||
msg: I18n.t('message_was_not_found'),
|
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
|
handle_errors and return
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,7 @@ class Epp::PollsController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def validate_poll
|
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)
|
return true if %w(ack req).include?(op)
|
||||||
epp_errors << { code: '2306', msg: I18n.t('errors.messages.attribute_op_is_invalid') }
|
epp_errors << { code: '2306', msg: I18n.t('errors.messages.attribute_op_is_invalid') }
|
||||||
false
|
false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue