mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Delete and transfer to cancan
This commit is contained in:
parent
8a8da67d38
commit
010cc81e10
4 changed files with 11 additions and 71 deletions
|
@ -1,8 +1,8 @@
|
||||||
class Epp::DomainsController < EppController
|
class Epp::DomainsController < EppController
|
||||||
skip_authorization_check # TODO: remove it
|
skip_authorization_check # TODO: remove it
|
||||||
|
|
||||||
before_action :find_domain, only: [:info, :renew, :update]
|
before_action :find_domain, only: [:info, :renew, :update, :transfer, :delete]
|
||||||
before_action :find_password, only: [:info, :update]
|
before_action :find_password, only: [:info, :update, :transfer, :delete]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize! :create, Epp::EppDomain
|
authorize! :create, Epp::EppDomain
|
||||||
|
@ -55,9 +55,7 @@ class Epp::DomainsController < EppController
|
||||||
# rubocop: disable Metrics/MethodLength
|
# rubocop: disable Metrics/MethodLength
|
||||||
|
|
||||||
def transfer
|
def transfer
|
||||||
@domain = find_domain
|
authorize! :transfer, @domain, @password
|
||||||
handle_errors(@domain) and return unless @domain
|
|
||||||
handle_errors(@domain) and return unless @domain.authenticate(domain_transfer_params[:pw])
|
|
||||||
|
|
||||||
if domain_transfer_params[:action] == 'query'
|
if domain_transfer_params[:action] == 'query'
|
||||||
if @domain.pending_transfer
|
if @domain.pending_transfer
|
||||||
|
@ -92,9 +90,6 @@ class Epp::DomainsController < EppController
|
||||||
# rubocop:disable Metrics/CyclomaticComplexity
|
# rubocop:disable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
@domain = find_domain
|
|
||||||
|
|
||||||
handle_errors(@domain) and return unless @domain
|
|
||||||
handle_errors(@domain) and return unless @domain.can_be_deleted?
|
handle_errors(@domain) and return unless @domain.can_be_deleted?
|
||||||
|
|
||||||
@domain.attach_legal_document(Epp::EppDomain.parse_legal_document_from_frame(params[:parsed_frame]))
|
@domain.attach_legal_document(Epp::EppDomain.parse_legal_document_from_frame(params[:parsed_frame]))
|
||||||
|
@ -164,31 +159,6 @@ class Epp::DomainsController < EppController
|
||||||
requires 'name'
|
requires 'name'
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_rem_params
|
|
||||||
ns_list = Epp::EppDomain.parse_nameservers_from_frame(params[:parsed_frame])
|
|
||||||
|
|
||||||
to_destroy = []
|
|
||||||
ns_list.each do |ns_attrs|
|
|
||||||
nameserver = @domain.nameservers.where(ns_attrs).try(:first)
|
|
||||||
if nameserver.blank?
|
|
||||||
epp_errors << {
|
|
||||||
code: '2303',
|
|
||||||
msg: I18n.t('nameserver_not_found'),
|
|
||||||
value: { obj: 'hostAttr', val: ns_attrs[:hostname] }
|
|
||||||
}
|
|
||||||
else
|
|
||||||
to_destroy << {
|
|
||||||
id: nameserver.id,
|
|
||||||
_destroy: 1
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
{
|
|
||||||
nameservers_attributes: to_destroy
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def domain_transfer_params
|
def domain_transfer_params
|
||||||
res = {}
|
res = {}
|
||||||
res[:pw] = params[:parsed_frame].css('pw').first.try(:text)
|
res[:pw] = params[:parsed_frame].css('pw').first.try(:text)
|
||||||
|
@ -217,17 +187,3 @@ class Epp::DomainsController < EppController
|
||||||
@password = params[:parsed_frame].css('authInfo pw').text
|
@password = params[:parsed_frame].css('authInfo pw').text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# return domain if domain.auth_info == params[:parsed_frame].css('authInfo pw').text
|
|
||||||
|
|
||||||
# if (domain.registrar != current_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: params[:parsed_frame].css('name').text.strip.downcase }
|
|
||||||
# }
|
|
||||||
# return nil
|
|
||||||
# end
|
|
||||||
|
|
||||||
# domain
|
|
||||||
|
|
|
@ -27,11 +27,12 @@ class Ability
|
||||||
can(:view_password, Epp::Contact) { |c| c.registrar_id == @user.registrar_id }
|
can(:view_password, Epp::Contact) { |c| c.registrar_id == @user.registrar_id }
|
||||||
|
|
||||||
# Epp::Domain
|
# Epp::Domain
|
||||||
can(:info, Epp::EppDomain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
can(:info, Epp::EppDomain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||||
can(:check, Epp::EppDomain)
|
can(:check, Epp::EppDomain)
|
||||||
can(:create, Epp::EppDomain)
|
can(:create, Epp::EppDomain)
|
||||||
can(:renew, Epp::EppDomain)
|
can(:renew, Epp::EppDomain)
|
||||||
can(:update, Epp::EppDomain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
can(:update, Epp::EppDomain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||||
|
can(:transfer, Epp::EppDomain) { |d, pw| d.auth_info == pw }
|
||||||
end
|
end
|
||||||
|
|
||||||
def user
|
def user
|
||||||
|
|
|
@ -11,9 +11,6 @@ class Nameserver < ActiveRecord::Base
|
||||||
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
|
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
|
||||||
# rubocop: enable Metrics/LineLength
|
# rubocop: enable Metrics/LineLength
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# after_destroy :domain_version
|
|
||||||
|
|
||||||
before_validation :normalize_attributes
|
before_validation :normalize_attributes
|
||||||
|
|
||||||
delegate :name, to: :domain, prefix: true
|
delegate :name, to: :domain, prefix: true
|
||||||
|
@ -34,26 +31,12 @@ class Nameserver < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# def snapshot
|
|
||||||
# {
|
|
||||||
# hostname: hostname,
|
|
||||||
# ipv4: ipv4,
|
|
||||||
# ipv6: ipv6
|
|
||||||
# }
|
|
||||||
# end
|
|
||||||
|
|
||||||
def normalize_attributes
|
def normalize_attributes
|
||||||
self.hostname = hostname.try(:strip).try(:downcase)
|
self.hostname = hostname.try(:strip).try(:downcase)
|
||||||
self.ipv4 = ipv4.try(:strip)
|
self.ipv4 = ipv4.try(:strip)
|
||||||
self.ipv6 = ipv6.try(:strip).try(:upcase)
|
self.ipv6 = ipv6.try(:strip).try(:upcase)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: remove old
|
|
||||||
# def domain_version
|
|
||||||
# domain.create_version if domain
|
|
||||||
# end
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
hostname
|
hostname
|
||||||
end
|
end
|
||||||
|
|
|
@ -984,7 +984,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
response = epp_plain_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
response[:result_code].should == '2201'
|
response[:result_code].should == '2201'
|
||||||
response[:msg].should == 'Authorization error [auth_info]'
|
response[:msg].should == 'Authorization error'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ignores transfer when owner registrar requests transfer' do
|
it 'ignores transfer when owner registrar requests transfer' do
|
||||||
|
@ -1031,7 +1031,7 @@ describe 'EPP Domain', epp: true do
|
||||||
epp_plain_request(xml, :xml) # transfer domain
|
epp_plain_request(xml, :xml) # transfer domain
|
||||||
response = epp_plain_request(xml, :xml) # attempt second transfer
|
response = epp_plain_request(xml, :xml) # attempt second transfer
|
||||||
response[:result_code].should == '2201'
|
response[:result_code].should == '2201'
|
||||||
response[:msg].should == 'Authorization error [auth_info]'
|
response[:msg].should == 'Authorization error'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue