REPP: Fix CC issues

This commit is contained in:
Karl Erik Õunapuu 2020-10-22 15:31:37 +03:00
parent 03d940a695
commit f2983da14c
No known key found for this signature in database
GPG key ID: C9DD647298A34764
2 changed files with 24 additions and 23 deletions

View file

@ -33,16 +33,20 @@ module Repp
initiate_transfer(transfer) initiate_transfer(transfer)
end end
render_success(data: {success: @successful, failed: @errors}) render_success(data: { success: @successful, failed: @errors })
end end
def initiate_transfer(transfer) def initiate_transfer(transfer)
domain = Epp::Domain.find_or_initialize_by(name: transfer[:domain_name]) domain = Epp::Domain.find_or_initialize_by(name: transfer[:domain_name])
action = Actions::DomainTransfer.new(domain, transfer[:transfer_code], current_user.registrar) action = Actions::DomainTransfer.new(domain, transfer[:transfer_code],
current_user.registrar)
@successful << { type: 'domain_transfer', domain_name: domain.name } and return if action.call if action.call
@successful << { type: 'domain_transfer', domain_name: domain.name }
@errors << { type: 'domain_transfer', domain_name: domain.name, errors: domain.errors[:epp_errors] } else
@errors << { type: 'domain_transfer', domain_name: domain.name,
errors: domain.errors[:epp_errors] }
end
end end
private private

View file

@ -14,10 +14,12 @@ module Actions
def call def call
return unless domain_exists? return unless domain_exists?
return unless run_validations return unless valid_transfer_code?
#return domain.pending_transfer if domain.pending_transfer run_validations
#attach_legal_document(::Deserializers::Xml::LegalDocument.new(frame).call)
# return domain.pending_transfer if domain.pending_transfer
# attach_legal_document(::Deserializers::Xml::LegalDocument.new(frame).call)
return if domain.errors[:epp_errors].any? return if domain.errors[:epp_errors].any?
@ -33,15 +35,12 @@ module Actions
end end
def run_validations def run_validations
return unless validate_transfer_code validate_registrar
return unless validate_registrar validate_eligilibty
return unless validate_eligilibty validate_not_discarded
return unless validate_not_discarded
true
end end
def validate_transfer_code def valid_transfer_code?
return true if transfer_code == domain.transfer_code return true if transfer_code == domain.transfer_code
domain.add_epp_error('2202', nil, nil, 'Invalid authorization information') domain.add_epp_error('2202', nil, nil, 'Invalid authorization information')
@ -49,24 +48,22 @@ module Actions
end end
def validate_registrar def validate_registrar
return true unless user == domain.registrar return unless user == domain.registrar
domain.add_epp_error('2002', nil, nil, I18n.t(:domain_already_belongs_to_the_querying_registrar)) domain.add_epp_error('2002', nil, nil,
false I18n.t(:domain_already_belongs_to_the_querying_registrar))
end end
def validate_eligilibty def validate_eligilibty
return true unless domain.non_transferable? return unless domain.non_transferable?
domain.add_epp_error('2304', nil, nil, 'Domain is not transferable??') domain.add_epp_error('2304', nil, nil, 'Object status prohibits operation')
false
end end
def validate_not_discarded def validate_not_discarded
return true unless domain.discarded? return unless domain.discarded?
domain.add_epp_error('2106', nil, nil, 'Object is not eligible for transfer') domain.add_epp_error('2106', nil, nil, 'Object is not eligible for transfer')
false
end end
def commit def commit