mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +02:00
Allow invalid ident update #2859
This commit is contained in:
parent
0944bd2077
commit
4a32c7641c
18 changed files with 101 additions and 32 deletions
|
@ -34,6 +34,7 @@ class Contact < ActiveRecord::Base
|
|||
after_initialize do
|
||||
self.statuses = [] if statuses.nil?
|
||||
self.status_notes = {} if status_notes.nil?
|
||||
self.ident_updated_at = Time.zone.now if new_record? && ident_updated_at.blank?
|
||||
end
|
||||
|
||||
before_validation :set_ident_country_code
|
||||
|
|
|
@ -10,9 +10,9 @@ module Depp
|
|||
|
||||
DISABLED = 'Disabled'
|
||||
DISCLOSURE_TYPES = [DISABLED, '1', '0']
|
||||
TYPES = %w( bic priv birthday )
|
||||
TYPES = %w( org priv birthday )
|
||||
SELECTION_TYPES = [
|
||||
['Business code', 'bic'],
|
||||
['Business code', 'org'],
|
||||
['Personal identification code', 'priv'],
|
||||
['Birthday', 'birthday']
|
||||
]
|
||||
|
@ -163,7 +163,7 @@ module Depp
|
|||
}
|
||||
|
||||
hash[:id] = nil if code.blank?
|
||||
create_xml = Depp::Contact.epp_xml.create(hash, extension_xml)
|
||||
create_xml = Depp::Contact.epp_xml.create(hash, extension_xml(:create))
|
||||
|
||||
data = Depp::Contact.user.request(create_xml)
|
||||
self.id = data.css('id').text
|
||||
|
@ -210,7 +210,7 @@ module Depp
|
|||
}
|
||||
}
|
||||
},
|
||||
extension_xml
|
||||
extension_xml(:update)
|
||||
)
|
||||
data = Depp::Contact.user.request(update_xml)
|
||||
handle_errors(data)
|
||||
|
@ -224,15 +224,25 @@ module Depp
|
|||
id: { value: id },
|
||||
authInfo: { pw: { value: password } }
|
||||
},
|
||||
extension_xml
|
||||
extension_xml(:delete)
|
||||
)
|
||||
data = Depp::Contact.user.request(delete_xml)
|
||||
handle_errors(data)
|
||||
end
|
||||
|
||||
def extension_xml
|
||||
def extension_xml(action)
|
||||
xml = { _anonymus: [] }
|
||||
ident = ident_xml[:_anonymus].try(:first) unless persisted?
|
||||
|
||||
case action
|
||||
when :create
|
||||
ident = ident_xml[:_anonymus].try(:first)
|
||||
when :update
|
||||
# detect if any ident has changed
|
||||
if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code)
|
||||
ident = ident_xml[:_anonymus].try(:first)
|
||||
end
|
||||
end
|
||||
|
||||
legal = legal_document_xml[:_anonymus].try(:first)
|
||||
xml[:_anonymus] << ident if ident.present?
|
||||
xml[:_anonymus] << legal if legal.present?
|
||||
|
|
|
@ -118,6 +118,7 @@ class Epp::Contact < Contact
|
|||
[:ident, :invalid_EE_identity_format],
|
||||
[:ident, :invalid_birthday_format],
|
||||
[:ident, :invalid_country_code],
|
||||
[:ident_type, :missing],
|
||||
[:code, :invalid],
|
||||
[:code, :too_long_contact_code]
|
||||
],
|
||||
|
@ -144,6 +145,20 @@ class Epp::Contact < Contact
|
|||
legal_frame = frame.css('legalDocument').first
|
||||
at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
|
||||
self.deliver_emails = true # turn on email delivery for epp
|
||||
|
||||
# allow to update ident code for legacy contacts
|
||||
if frame.css('ident').first.present?
|
||||
if ident_updated_at.present?
|
||||
throw :epp_error, {
|
||||
code: '2306',
|
||||
msg: I18n.t(:ident_update_error)
|
||||
}
|
||||
else
|
||||
at.merge!(self.class.ident_attrs(frame.css('ident').first))
|
||||
self.ident_updated_at = Time.zone.now
|
||||
end
|
||||
end
|
||||
|
||||
super(at)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue