mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
registrant update change #2557
This commit is contained in:
parent
51d22af52b
commit
64bd2b957f
9 changed files with 68 additions and 35 deletions
|
@ -20,7 +20,6 @@ class Registrant::DomainUpdateConfirmsController < RegistrantController
|
||||||
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||||
domain_name: @domain.name,
|
domain_name: @domain.name,
|
||||||
verification_token: params[:token])
|
verification_token: params[:token])
|
||||||
|
|
||||||
if params[:rejected]
|
if params[:rejected]
|
||||||
if @registrant_verification.domain_registrant_change_reject!
|
if @registrant_verification.domain_registrant_change_reject!
|
||||||
flash[:notice] = t(:registrant_domain_verification_rejected)
|
flash[:notice] = t(:registrant_domain_verification_rejected)
|
||||||
|
|
16
app/jobs/domain_confirm_job.rb
Normal file
16
app/jobs/domain_confirm_job.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
class DomainConfirmJob < Que::Job
|
||||||
|
def run(domain_id, action)
|
||||||
|
# it's recommended to keep transaction against job table as short as possible.
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
domain = Epp::Domain.find(domain_id)
|
||||||
|
case action
|
||||||
|
when RegistrantVerification::CONFIRMED
|
||||||
|
domain.apply_pending_update!
|
||||||
|
domain.clean_pendings!
|
||||||
|
when RegistrantVerification::REJECTED
|
||||||
|
domain.clean_pendings!
|
||||||
|
end
|
||||||
|
destroy # it's best to destroy the job in the same transaction
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -54,6 +54,11 @@ class Domain < ActiveRecord::Base
|
||||||
delegate :name, to: :registrar, prefix: true
|
delegate :name, to: :registrar, prefix: true
|
||||||
delegate :street, to: :registrar, prefix: true
|
delegate :street, to: :registrar, prefix: true
|
||||||
|
|
||||||
|
after_initialize :init_default_values
|
||||||
|
def init_default_values
|
||||||
|
self.pending_json = {} if pending_json.blank?
|
||||||
|
end
|
||||||
|
|
||||||
before_create :generate_auth_info
|
before_create :generate_auth_info
|
||||||
before_create :set_validity_dates
|
before_create :set_validity_dates
|
||||||
before_update :manage_statuses
|
before_update :manage_statuses
|
||||||
|
@ -269,6 +274,19 @@ class Domain < ActiveRecord::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def preclean_pendings
|
||||||
|
self.registrant_verification_token = nil
|
||||||
|
self.registrant_verification_asked_at = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def clean_pendings!
|
||||||
|
preclean_pendings
|
||||||
|
self.pending_json = {}
|
||||||
|
domain_statuses.where(value: DomainStatus::PENDING_UPDATE).destroy_all
|
||||||
|
domain_statuses.where(value: DomainStatus::PENDING_DELETE).destroy_all
|
||||||
|
save
|
||||||
|
end
|
||||||
|
|
||||||
def pending_update?
|
def pending_update?
|
||||||
(domain_statuses.pluck(:value) & %W(
|
(domain_statuses.pluck(:value) & %W(
|
||||||
#{DomainStatus::PENDING_UPDATE}
|
#{DomainStatus::PENDING_UPDATE}
|
||||||
|
@ -280,9 +298,10 @@ class Domain < ActiveRecord::Base
|
||||||
self.epp_pending_update = true # for epp
|
self.epp_pending_update = true # for epp
|
||||||
|
|
||||||
return true unless registrant_verification_asked?
|
return true unless registrant_verification_asked?
|
||||||
pending_json_cache = all_changes
|
pending_json_cache = pending_json
|
||||||
token = registrant_verification_token
|
token = registrant_verification_token
|
||||||
asked_at = registrant_verification_asked_at
|
asked_at = registrant_verification_asked_at
|
||||||
|
changes_cache = changes
|
||||||
|
|
||||||
DomainMailer.registrant_pending_updated(self).deliver_now
|
DomainMailer.registrant_pending_updated(self).deliver_now
|
||||||
|
|
||||||
|
@ -291,10 +310,12 @@ class Domain < ActiveRecord::Base
|
||||||
self.pending_json = pending_json_cache
|
self.pending_json = pending_json_cache
|
||||||
self.registrant_verification_token = token
|
self.registrant_verification_token = token
|
||||||
self.registrant_verification_asked_at = asked_at
|
self.registrant_verification_asked_at = asked_at
|
||||||
|
self.pending_json[:domain] = changes_cache
|
||||||
domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
|
domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrant_update_confirmable?(token)
|
def registrant_update_confirmable?(token)
|
||||||
|
return true if Rails.env.development?
|
||||||
return false unless pending_update?
|
return false unless pending_update?
|
||||||
return false if registrant_verification_token.blank?
|
return false if registrant_verification_token.blank?
|
||||||
return false if registrant_verification_asked_at.blank?
|
return false if registrant_verification_asked_at.blank?
|
||||||
|
@ -304,6 +325,7 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrant_delete_confirmable?(token)
|
def registrant_delete_confirmable?(token)
|
||||||
|
return true if Rails.env.development?
|
||||||
return false unless pending_delete?
|
return false unless pending_delete?
|
||||||
return false if registrant_verification_token.blank?
|
return false if registrant_verification_token.blank?
|
||||||
return false if registrant_verification_asked_at.blank?
|
return false if registrant_verification_asked_at.blank?
|
||||||
|
@ -320,7 +342,9 @@ class Domain < ActiveRecord::Base
|
||||||
registrant_verification_asked_at.present? && registrant_verification_token.present?
|
registrant_verification_asked_at.present? && registrant_verification_token.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrant_verification_asked!
|
def registrant_verification_asked!(frame_str, current_user_id)
|
||||||
|
self.pending_json['frame'] = frame_str
|
||||||
|
self.pending_json['current_user_id'] = current_user_id
|
||||||
self.registrant_verification_asked_at = Time.zone.now
|
self.registrant_verification_asked_at = Time.zone.now
|
||||||
self.registrant_verification_token = SecureRandom.hex(42)
|
self.registrant_verification_token = SecureRandom.hex(42)
|
||||||
end
|
end
|
||||||
|
@ -393,12 +417,10 @@ class Domain < ActiveRecord::Base
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_registrant_name
|
def pending_registrant
|
||||||
return '' if pending_json.blank?
|
return '' if pending_json.blank?
|
||||||
return '' if pending_json['domain'].blank?
|
|
||||||
return '' if pending_json['domain']['registrant_id'].blank?
|
return '' if pending_json['domain']['registrant_id'].blank?
|
||||||
registrant = Registrant.find_by(id: pending_json['domain']['registrant_id'].last)
|
Registrant.find_by(id: pending_json['domain']['registrant_id'].last)
|
||||||
registrant.try(:name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Lint/Loop
|
# rubocop:disable Lint/Loop
|
||||||
|
@ -465,17 +487,6 @@ class Domain < ActiveRecord::Base
|
||||||
log
|
log
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_changes
|
|
||||||
all_changes = HashWithIndifferentAccess.new
|
|
||||||
all_changes[:domain] = changes
|
|
||||||
all_changes[:admin_contacts] = admin_contacts.map(&:changes)
|
|
||||||
all_changes[:tech_contacts] = tech_contacts.map(&:changes)
|
|
||||||
all_changes[:nameservers] = nameservers.map(&:changes)
|
|
||||||
all_changes[:registrant] = registrant.try(:changes)
|
|
||||||
all_changes[:domain_statuses] = domain_statuses.map(&:changes)
|
|
||||||
all_changes
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_whois_record
|
def update_whois_record
|
||||||
whois_record.blank? ? create_whois_record : whois_record.save
|
whois_record.blank? ? create_whois_record : whois_record.save
|
||||||
end
|
end
|
||||||
|
|
|
@ -394,14 +394,25 @@ class Epp::Domain < Domain
|
||||||
at[:dnskeys_attributes] += at_add[:dnskeys_attributes]
|
at[:dnskeys_attributes] += at_add[:dnskeys_attributes]
|
||||||
at[:domain_statuses_attributes] += at_add[:domain_statuses_attributes]
|
at[:domain_statuses_attributes] += at_add[:domain_statuses_attributes]
|
||||||
|
|
||||||
if frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes'
|
if frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes' && !pending_update?
|
||||||
registrant_verification_asked!
|
registrant_verification_asked!(frame.to_s, current_user.id)
|
||||||
end
|
end
|
||||||
self.deliver_emails = true # turn on email delivery for epp
|
self.deliver_emails = true # turn on email delivery for epp
|
||||||
|
|
||||||
errors.empty? && super(at)
|
errors.empty? && super(at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apply_pending_update!
|
||||||
|
preclean_pendings
|
||||||
|
user = ApiUser.find(pending_json['current_user_id'])
|
||||||
|
frame = Nokogiri::XML(pending_json['frame'])
|
||||||
|
domain_statuses.where(value: DomainStatus::PENDING_UPDATE).destroy_all
|
||||||
|
domain_statuses.reload
|
||||||
|
if update(frame, user)
|
||||||
|
clean_pendings!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def attach_legal_document(legal_document_data)
|
def attach_legal_document(legal_document_data)
|
||||||
return unless legal_document_data
|
return unless legal_document_data
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,16 @@ class RegistrantVerification < ActiveRecord::Base
|
||||||
def domain_registrant_change_confirm!
|
def domain_registrant_change_confirm!
|
||||||
self.action_type = DOMAIN_REGISTRANT_CHANGE
|
self.action_type = DOMAIN_REGISTRANT_CHANGE
|
||||||
self.action = CONFIRMED
|
self.action = CONFIRMED
|
||||||
save
|
if save
|
||||||
|
DomainConfirmJob.enqueue domain.id, CONFIRMED
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_registrant_change_reject!
|
def domain_registrant_change_reject!
|
||||||
self.action_type = DOMAIN_REGISTRANT_CHANGE
|
self.action_type = DOMAIN_REGISTRANT_CHANGE
|
||||||
self.action = REJECTED
|
self.action = REJECTED
|
||||||
save
|
if save
|
||||||
|
DomainConfirmJob.enqueue domain.id, REJECTED
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,6 @@ Isikukood: <%= @domain.registrant_ident %><br>
|
||||||
<% else %>
|
<% else %>
|
||||||
Äriregistrikood: <%= @domain.registrant_ident %><br>
|
Äriregistrikood: <%= @domain.registrant_ident %><br>
|
||||||
<% end %>
|
<% end %>
|
||||||
Epost: <%= @domain.registrant_email %><br>
|
|
||||||
Tel: <%= @domain.registrant_phone %><br>
|
|
||||||
Tänav: <%= @domain.registrant_street %><br>
|
Tänav: <%= @domain.registrant_street %><br>
|
||||||
Linn: <%= @domain.registrant_city %><br>
|
Linn: <%= @domain.registrant_city %><br>
|
||||||
Riik: <%= @domain.registrant_country %>
|
Riik: <%= @domain.registrant_country %>
|
||||||
|
@ -34,8 +32,6 @@ Personal code: <%= @domain.registrant_ident %><br>
|
||||||
<% else %>
|
<% else %>
|
||||||
Business Registry code: <%= @domain.registrant_ident %><br>
|
Business Registry code: <%= @domain.registrant_ident %><br>
|
||||||
<% end %>
|
<% end %>
|
||||||
E-mail: <%= @domain.registrant_email %><br>
|
|
||||||
Tel: <%= @domain.registrant_phone %><br>
|
|
||||||
Street: <%= @domain.registrant_street %><br>
|
Street: <%= @domain.registrant_street %><br>
|
||||||
City: <%= @domain.registrant_city %><br>
|
City: <%= @domain.registrant_city %><br>
|
||||||
Country: <%= @domain.registrant_country %>
|
Country: <%= @domain.registrant_country %>
|
||||||
|
|
|
@ -9,8 +9,6 @@ Isikukood: <%= @domain.registrant_ident %>
|
||||||
<% else %>
|
<% else %>
|
||||||
Äriregistrikood: <%= @domain.registrant_ident %>
|
Äriregistrikood: <%= @domain.registrant_ident %>
|
||||||
<% end %>
|
<% end %>
|
||||||
Epost: <%= @domain.registrant_email %>
|
|
||||||
Tel: <%= @domain.registrant_phone %>
|
|
||||||
Tänav: <%= @domain.registrant_street %>
|
Tänav: <%= @domain.registrant_street %>
|
||||||
Linn: <%= @domain.registrant_city %>
|
Linn: <%= @domain.registrant_city %>
|
||||||
Riik: <%= @domain.registrant_country %>
|
Riik: <%= @domain.registrant_country %>
|
||||||
|
@ -34,8 +32,6 @@ Personal code: <%= @domain.registrant_ident %>
|
||||||
<% else %>
|
<% else %>
|
||||||
Business Registry code: <%= @domain.registrant_ident %>
|
Business Registry code: <%= @domain.registrant_ident %>
|
||||||
<% end %>
|
<% end %>
|
||||||
E-mail: <%= @domain.registrant_email %>
|
|
||||||
Tel: <%= @domain.registrant_phone %>
|
|
||||||
Street: <%= @domain.registrant_street %>
|
Street: <%= @domain.registrant_street %>
|
||||||
City: <%= @domain.registrant_city %>
|
City: <%= @domain.registrant_city %>
|
||||||
Country: <%= @domain.registrant_country %>
|
Country: <%= @domain.registrant_country %>
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
%p= t(:new_pending_registrant) + ':'
|
%p= t(:new_pending_registrant) + ':'
|
||||||
.column-values
|
.column-values
|
||||||
%p= @domain.name
|
%p= @domain.name
|
||||||
%p= @domain.registrant_name
|
%p= "#{@domain.registrant_name} (#{@domain.registrant.ident})"
|
||||||
%p= @domain.pending_registrant_name
|
%p= "#{@domain.pending_registrant.try(:name)} (#{@domain.pending_registrant.try(:ident)})"
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-center
|
.col-md-12.text-center
|
||||||
|
|
|
@ -788,8 +788,8 @@ en:
|
||||||
reject_domain_registrant_update: 'Reject domain ownership change'
|
reject_domain_registrant_update: 'Reject domain ownership change'
|
||||||
domain_registrant_change_title: 'Please confirm or reject domain ownership change'
|
domain_registrant_change_title: 'Please confirm or reject domain ownership change'
|
||||||
domain_registrant_change_body: 'There is a request to change domain ownership. Before doing it we need your confirmation.'
|
domain_registrant_change_body: 'There is a request to change domain ownership. Before doing it we need your confirmation.'
|
||||||
new_pending_registrant: 'New owner'
|
new_pending_registrant: 'New registrant'
|
||||||
current_registrant: 'Current owner'
|
current_registrant: 'Current registrant'
|
||||||
registrant_domain_verification_failed: 'Domain verification not available'
|
registrant_domain_verification_failed: 'Domain verification not available'
|
||||||
domain_registrant_change_confirmed_title: 'Domain owner change has been confirmed'
|
domain_registrant_change_confirmed_title: 'Domain owner change has been confirmed'
|
||||||
domain_registrant_change_confirmed_body: 'You have successfully confirmed domain owner change.'
|
domain_registrant_change_confirmed_body: 'You have successfully confirmed domain owner change.'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue