Merge branch 'master' of github.com:internetee/registry

Conflicts:
	app/models/nameserver.rb
This commit is contained in:
Andres Keskküla 2014-10-20 16:42:35 +03:00
commit dd8410248e
12 changed files with 113 additions and 79 deletions

View file

@ -28,7 +28,7 @@ class Client::DomainTransfersController < ClientController
end
@domain_transfer = @domain.domain_transfers.create(domain_transfer_params)
@domain_transfer.approve_as_server if SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i == 0
@domain_transfer.approve_as_server if Setting.transfer_wait_time == 0
if @domain_transfer.approved?
flash[:notice] = I18n.t('shared.domain_transfer_approved')

View file

@ -167,22 +167,25 @@ module Epp::DomainsHelper
## SHARED
def find_domain(secure = { secure: true })
domain = Epp::EppDomain.find_by(name: @ph[:name])
domain = Epp::EppDomain.find_by(name: @ph[:name].strip.downcase)
unless domain
epp_errors << {
code: '2303',
msg: I18n.t('errors.messages.epp_domain_not_found'),
value: { obj: 'name', val: @ph[:name] }
value: { obj: 'name', val: @ph[:name].strip.downcase }
}
return nil
end
if domain.registrar != current_epp_user.registrar && secure[:secure] == true
@ph[:authInfo] ||= {}
return domain if domain.auth_info == @ph[:authInfo][:pw]
if (domain.registrar != current_epp_user.registrar && secure[:secure] == true) &&
epp_errors << {
code: '2302',
msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'),
value: { obj: 'name', val: @ph[:name] }
value: { obj: 'name', val: @ph[:name].strip.downcase }
}
return nil
end

View file

@ -82,6 +82,7 @@ class Domain < ActiveRecord::Base
def name=(value)
value.strip!
value.downcase!
self[:name] = SimpleIDN.to_unicode(value)
self[:name_puny] = SimpleIDN.to_ascii(value)
self[:name_dirty] = value

View file

@ -477,6 +477,8 @@ class Epp::EppDomain < Domain
res = []
domains.each do |x|
x.strip!
x.downcase!
unless DomainNameValidator.validate_format(x)
res << { name: x, avail: 0, reason: 'invalid format' }
next

View file

@ -13,6 +13,8 @@ class Nameserver < ActiveRecord::Base
# archiving
has_paper_trail class_name: 'NameserverVersion'
before_validation :normalize_attributes
def epp_code_map
{
'2302' => [
@ -37,6 +39,12 @@ class Nameserver < ActiveRecord::Base
}
end
def normalize_attributes
self.hostname = hostname.try(:strip).try(:downcase)
self.ipv4 = ipv4.try(:strip)
self.ipv6 = ipv6.try(:strip).try(:upcase)
end
def to_s
hostname
end

View file

@ -24,23 +24,19 @@ xml.epp_head do
xml.tag!('domain:ns') do
@domain.nameservers.each do |x|
if x.ipv4.present? || x.ipv6.present?
xml.tag!('domain:hostAttr') do
xml.tag!('domain:hostName', x.hostname)
xml.tag!('domain:hostAddr', x.ipv4, 'ip' => 'v4') if x.ipv4.present?
xml.tag!('domain:hostAddr', x.ipv6, 'ip' => 'v6') if x.ipv6.present?
end
else
xml.tag!('domain:hostObj', x.hostname)
xml.tag!('domain:hostAttr') do
xml.tag!('domain:hostName', x.hostname)
xml.tag!('domain:hostAddr', x.ipv4, 'ip' => 'v4') if x.ipv4.present?
xml.tag!('domain:hostAddr', x.ipv6, 'ip' => 'v6') if x.ipv6.present?
end
end
end
## TODO Find out what this domain:host is all about
xml.tag!('domain:clID', @domain.owner_contact_code)
xml.tag!('domain:clID', @domain.registrar_name)
xml.tag!('domain:crID', @domain.registrar_name) if @domain.registrar #TODO Registrar has to be specified
xml.tag!('domain:crID', @domain.versions.first.try(:reify).try(:registrar) || @domain.registrar) #TODO Registrar has to be specified
xml.tag!('domain:crDate', @domain.created_at)