mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 03:37:28 +02:00
Add epp errors tto the concern itself
This commit is contained in:
parent
d4775ba5c5
commit
e15fed2cd0
5 changed files with 19 additions and 7 deletions
|
@ -94,7 +94,7 @@ module Epp
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_errors(obj = nil)
|
def handle_errors(obj = nil)
|
||||||
@errors ||= []
|
@errors ||= ActiveModel::Errors.new(self)
|
||||||
|
|
||||||
if obj
|
if obj
|
||||||
obj.construct_epp_errors
|
obj.construct_epp_errors
|
||||||
|
|
|
@ -55,13 +55,13 @@ module Epp
|
||||||
|
|
||||||
def renew
|
def renew
|
||||||
authorize! :renew, Epp::Contact
|
authorize! :renew, Epp::Contact
|
||||||
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') }
|
epp_errors.add(:epp_errors, code: '2101', msg: t(:'errors.messages.unimplemented_command'))
|
||||||
handle_errors
|
handle_errors
|
||||||
end
|
end
|
||||||
|
|
||||||
def transfer
|
def transfer
|
||||||
authorize! :transfer, Epp::Contact
|
authorize! :transfer, Epp::Contact
|
||||||
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') }
|
epp_errors.add(:epp_errors, code: '2101', msg: t(:'errors.messages.unimplemented_command'))
|
||||||
handle_errors
|
handle_errors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,10 @@ module Epp
|
||||||
update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame],
|
update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame],
|
||||||
registrar_id).call
|
registrar_id).call
|
||||||
action = Actions::DomainUpdate.new(@domain, update_params, false)
|
action = Actions::DomainUpdate.new(@domain, update_params, false)
|
||||||
(handle_errors(@domain) and return) unless action.call
|
unless action.call
|
||||||
|
handle_errors(@domain)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
pending = @domain.epp_pending_update.present?
|
pending = @domain.epp_pending_update.present?
|
||||||
render_epp_response("/epp/domains/success#{'_pending' if pending}")
|
render_epp_response("/epp/domains/success#{'_pending' if pending}")
|
||||||
|
|
|
@ -113,11 +113,20 @@ module EppErrors
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_epp_error(code, obj, val, msg)
|
def add_epp_error(code, obj, val, msg)
|
||||||
errors[:epp_errors] ||= []
|
|
||||||
t = errors.generate_message(*msg) if msg.is_a?(Array)
|
t = errors.generate_message(*msg) if msg.is_a?(Array)
|
||||||
t = msg if msg.is_a?(String)
|
t = msg if msg.is_a?(String)
|
||||||
err = { code: code, msg: t }
|
err = { code: code, msg: t }
|
||||||
|
val = check_for_status(code, obj, val)
|
||||||
err[:value] = { val: val, obj: obj } if val.present?
|
err[:value] = { val: val, obj: obj } if val.present?
|
||||||
errors[:epp_errors] << err
|
self.errors.add(:epp_errors, err)
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_for_status(code, obj, val)
|
||||||
|
if code == '2304' && val.present? && val == DomainStatus::SERVER_DELETE_PROHIBITED &&
|
||||||
|
obj == 'status'
|
||||||
|
DomainStatus::PENDING_UPDATE
|
||||||
|
else
|
||||||
|
val
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ xml.epp_head do
|
||||||
xml.response do
|
xml.response do
|
||||||
@errors.each do |error|
|
@errors.each do |error|
|
||||||
x = error&.options
|
x = error&.options
|
||||||
next if x.empty?
|
next if x.empty? || x == { value: nil }
|
||||||
xml.result('code' => x[:code]) do
|
xml.result('code' => x[:code]) do
|
||||||
xml.msg(x[:msg], 'lang' => 'en')
|
xml.msg(x[:msg], 'lang' => 'en')
|
||||||
model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize
|
model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue