Handle blocked and reserved domains in EPP domain:info

Closes #597
This commit is contained in:
Artur Beljajev 2019-02-01 13:20:58 +02:00
parent f1148bd4f4
commit 36a53bd11a
6 changed files with 117 additions and 19 deletions

View file

@ -4,9 +4,9 @@ class Epp::DomainsController < EppController
skip_authorization_check only: :info
def info
if Domain.release_to_auction
domain_name = DNS::DomainName.new(params[:parsed_frame].at_css('name').text.strip.downcase)
domain_name = DNS::DomainName.new(params[:parsed_frame].at_css('name').text.strip.downcase)
if Domain.release_to_auction
if domain_name.at_auction?
@name = domain_name
@status = 'At auction'
@ -25,22 +25,34 @@ class Epp::DomainsController < EppController
end
end
find_domain
find_password
authorize! :info, @domain, @password
if domain_name.registered?
find_domain
find_password
authorize! :info, @domain, @password
@hosts = params[:parsed_frame].css('name').first['hosts'] || 'all'
@hosts = params[:parsed_frame].css('name').first['hosts'] || 'all'
case @hosts
when 'del'
@nameservers = @domain.delegated_nameservers.sort
when 'sub'
@nameservers = @domain.subordinate_nameservers.sort
when 'all'
@nameservers = @domain.nameservers.sort
case @hosts
when 'del'
@nameservers = @domain.delegated_nameservers.sort
when 'sub'
@nameservers = @domain.subordinate_nameservers.sort
when 'all'
@nameservers = @domain.nameservers.sort
end
render_epp_response '/epp/domains/info/registered_domain'
else
if domain_name.blocked?
@name = domain_name
@status = 'Blocked'
render_epp_response '/epp/domains/info/unregistered_domain'
elsif domain_name.reserved?
@name = domain_name
@status = 'Reserved'
render_epp_response '/epp/domains/info/unregistered_domain'
end
end
render_epp_response '/epp/domains/info'
end
def create

View file

@ -57,10 +57,6 @@ module DNS
name
end
private
attr_reader :name
def registered?
Domain.find_by_idn(name)
end
@ -69,6 +65,18 @@ module DNS
BlockedDomain.where(name: name).any?
end
def reserved?
ReservedDomain.where(name: name).any?
end
def to_s
name
end
private
attr_reader :name
def zone_with_same_origin?
DNS::Zone.where(origin: name).any?
end

View file

@ -0,0 +1,16 @@
xml.epp_head do
xml.response do
xml.result code: '1000' do
xml.msg 'Command completed successfully'
end
xml.resData do
xml.tag! 'domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' do
xml.tag! 'domain:name', @name
xml.tag! 'domain:status', 's' => @status
end
end
render 'epp/shared/trID', builder: xml
end
end