mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
parent
340e61804b
commit
4b836f1476
23 changed files with 54 additions and 47 deletions
|
@ -6,11 +6,11 @@ module Repp
|
|||
post '/' do
|
||||
params['domainTransfers'].each do |domain_transfer|
|
||||
domain_name = domain_transfer['domainName']
|
||||
auth_info = domain_transfer['authInfo']
|
||||
transfer_code = domain_transfer['transferCode']
|
||||
new_registrar = current_user.registrar
|
||||
|
||||
domain = Domain.find_by(name: domain_name)
|
||||
domain.transfer(registrar: new_registrar, auth_info: auth_info)
|
||||
domain.transfer(registrar: new_registrar, transfer_code: transfer_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ module Repp
|
|||
domain = ident =~ /\A[0-9]+\z/ ? Domain.find_by(id: ident) : Domain.find_by_idn(ident)
|
||||
|
||||
error! I18n.t('errors.messages.epp_domain_not_found'), 404 unless domain
|
||||
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.auth_info.eql? request.headers['Auth-Code']
|
||||
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.transfer_code.eql? request.headers['Auth-Code']
|
||||
|
||||
contact_repp_json = proc{|contact|
|
||||
contact.as_json.slice("code", "name", "ident", "ident_type", "ident_country_code", "phone", "email", "street", "city", "zip","country_code", "statuses")
|
||||
|
|
|
@ -54,14 +54,14 @@ class Ability
|
|||
# can(:create, :epp_request)
|
||||
|
||||
# Epp::Domain
|
||||
can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || pw.blank? ? true : d.auth_info == pw }
|
||||
can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || pw.blank? ? true : d.transfer_code == pw }
|
||||
can(:check, Epp::Domain)
|
||||
can(:create, Epp::Domain)
|
||||
can(:renew, Epp::Domain) { |d| d.registrar_id == @user.registrar_id }
|
||||
can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
can(:transfer, Epp::Domain) { |d, pw| d.auth_info == pw }
|
||||
can(:view_password, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
|
||||
can(:transfer, Epp::Domain) { |d, pw| d.transfer_code == pw }
|
||||
can(:view_password, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
|
||||
can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
|
||||
|
||||
# Epp::Contact
|
||||
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw }
|
||||
|
|
|
@ -2,17 +2,17 @@ module Concerns::Domain::Transferable
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_initialize :generate_auth_info, if: :new_record?
|
||||
after_initialize :generate_transfer_code, if: :new_record?
|
||||
end
|
||||
|
||||
def transfer(new_registrar)
|
||||
self.registrar = new_registrar
|
||||
generate_auth_info
|
||||
generate_transfer_code
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_auth_info
|
||||
self.auth_info = SecureRandom.hex
|
||||
def generate_transfer_code
|
||||
self.transfer_code = SecureRandom.hex
|
||||
end
|
||||
end
|
||||
|
|
|
@ -100,7 +100,7 @@ class Epp::Domain < Domain
|
|||
[:puny_label, :too_long, { obj: 'name', val: name_puny }]
|
||||
],
|
||||
'2201' => [ # Authorisation error
|
||||
[:auth_info, :wrong_pw]
|
||||
[:transfer_code, :wrong_pw]
|
||||
],
|
||||
'2202' => [
|
||||
[:base, :invalid_auth_information_reserved]
|
||||
|
@ -182,7 +182,7 @@ class Epp::Domain < Domain
|
|||
# at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action)
|
||||
|
||||
pw = frame.css('authInfo > pw').text
|
||||
at[:auth_info] = pw if pw.present?
|
||||
at[:transfer_code] = pw if pw.present?
|
||||
|
||||
if new_record?
|
||||
dnskey_frame = frame.css('extension create')
|
||||
|
@ -722,7 +722,7 @@ class Epp::Domain < Domain
|
|||
if dt.approved?
|
||||
transfer_contacts(current_user.registrar_id)
|
||||
dt.notify_losing_registrar(old_contact_codes, old_registrant_code)
|
||||
generate_auth_info
|
||||
generate_transfer_code
|
||||
self.registrar = current_user.registrar
|
||||
end
|
||||
|
||||
|
@ -751,7 +751,7 @@ class Epp::Domain < Domain
|
|||
)
|
||||
|
||||
transfer_contacts(pt.transfer_to_id)
|
||||
generate_auth_info
|
||||
generate_transfer_code
|
||||
self.registrar = pt.transfer_to
|
||||
|
||||
attach_legal_document(self.class.parse_legal_document_from_frame(frame))
|
||||
|
@ -872,7 +872,7 @@ class Epp::Domain < Domain
|
|||
|
||||
# For domain transfer
|
||||
def authenticate(pw)
|
||||
errors.add(:auth_info, :wrong_pw) if pw != auth_info
|
||||
errors.add(:transfer_code, :wrong_pw) if pw != transfer_code
|
||||
errors.empty?
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class DomainPresenter
|
||||
delegate :name, :auth_info, :registrant_name, :registrant_id, :registrant_code, to: :domain
|
||||
delegate :name, :transfer_code, :registrant_name, :registrant_id, :registrant_code, to: :domain
|
||||
|
||||
def initialize(domain:, view:)
|
||||
@domain = domain
|
||||
|
|
|
@ -19,7 +19,7 @@ class Registrar::DomainListCSVPresenter
|
|||
def header
|
||||
columns = %w(
|
||||
domain_name
|
||||
auth_info
|
||||
transfer_code
|
||||
registrant_name
|
||||
registrant_code
|
||||
expire_time
|
||||
|
@ -33,7 +33,7 @@ class Registrar::DomainListCSVPresenter
|
|||
def domain_to_row(domain:)
|
||||
row = []
|
||||
row[0] = domain.name
|
||||
row[1] = domain.auth_info
|
||||
row[1] = domain.transfer_code
|
||||
row[2] = domain.registrant_name
|
||||
row[3] = domain.registrant_code
|
||||
row[4] = domain.expire_date
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<dt><%= t(:registrar_name) %></dt>
|
||||
<dd><%= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) %></dd>
|
||||
|
||||
<dt><%= Domain.human_attribute_name :auth_info %></dt>
|
||||
<dt><%= Domain.human_attribute_name :transfer_code %></dt>
|
||||
<dd>
|
||||
<%= tag :input, type: 'text', value: @domain.auth_info, readonly: true,
|
||||
<%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true,
|
||||
class: 'form-control input-sm' %>
|
||||
</dd>
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ xml.epp_head do
|
|||
|
||||
if can? :view_password, @domain, @password
|
||||
xml.tag!('domain:authInfo') do
|
||||
xml.tag!('domain:pw', @domain.auth_info)
|
||||
xml.tag!('domain:pw', @domain.transfer_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<dt><%= t(:registrar_name) %></dt>
|
||||
<dd><%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %></dd>
|
||||
|
||||
<dt><%= Domain.human_attribute_name :auth_info %></dt>
|
||||
<dt><%= Domain.human_attribute_name :transfer_code %></dt>
|
||||
<dd>
|
||||
<%= tag :input, type: 'text', value: @domain.auth_info, readonly: true,
|
||||
<%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true,
|
||||
class: 'form-control input-sm' %>
|
||||
</dd>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt><%= Domain.human_attribute_name :auth_info %></dt>
|
||||
<dt><%= Domain.human_attribute_name :transfer_code %></dt>
|
||||
<dd>
|
||||
<% if @data.css('pw').text.present? %>
|
||||
<%= tag(:input, type: 'text', value: @data.css('pw').text, readonly: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue