mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 12:08:27 +02:00
Registrant domain delete confirmation #2557
This commit is contained in:
parent
f34a7193d4
commit
912ad63fd7
7 changed files with 130 additions and 16 deletions
|
@ -1,12 +1,43 @@
|
||||||
class Registrant::DomainDeleteConfirmsController < RegistrantController
|
class Registrant::DomainDeleteConfirmsController < RegistrantController
|
||||||
skip_before_action :authenticate_user!, only: [:show, :create]
|
skip_before_action :authenticate_user!, only: [:show, :update]
|
||||||
skip_authorization_check only: [:show, :create]
|
skip_authorization_check only: [:show, :update]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
return if params[:confirmed] || params[:rejected]
|
||||||
@domain = Domain.find(params[:id])
|
@domain = Domain.find(params[:id])
|
||||||
@domain = nil unless @domain.registrant_delete_confirmable?(params[:token])
|
@domain = nil unless @domain.registrant_delete_confirmable?(params[:token])
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
# # rubocop: disable Metrics/PerceivedComplexity
|
||||||
|
# # rubocop: disable Metrics/CyclomaticComplexity
|
||||||
|
def update
|
||||||
|
@domain = Domain.find(params[:id])
|
||||||
|
unless @domain.registrant_delete_confirmable?(params[:token])
|
||||||
|
flash[:alert] = t(:registrant_domain_verification_failed)
|
||||||
|
return render 'show'
|
||||||
|
end
|
||||||
|
|
||||||
|
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
|
||||||
|
domain_name: @domain.name,
|
||||||
|
verification_token: params[:token])
|
||||||
|
if params[:rejected]
|
||||||
|
if @registrant_verification.domain_registrant_delete_reject!
|
||||||
|
flash[:notice] = t(:registrant_domain_verification_rejected)
|
||||||
|
redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true)
|
||||||
|
else
|
||||||
|
flash[:alert] = t(:registrant_domain_verification_rejected_failed)
|
||||||
|
return render 'show'
|
||||||
|
end
|
||||||
|
elsif params[:confirmed]
|
||||||
|
if @registrant_verification.domain_registrant_delete_confirm!
|
||||||
|
flash[:notice] = t(:registrant_domain_verification_confirmed)
|
||||||
|
redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true)
|
||||||
|
else
|
||||||
|
flash[:alert] = t(:registrant_domain_verification_confirmed_failed)
|
||||||
|
return render 'show'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop: enable Metrics/PerceivedComplexity
|
||||||
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
end
|
end
|
||||||
|
|
16
app/jobs/domain_delete_confirm_job.rb
Normal file
16
app/jobs/domain_delete_confirm_job.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
class DomainDeleteConfirmJob < 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_delete!
|
||||||
|
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
|
|
@ -1,4 +1,4 @@
|
||||||
class DomainConfirmJob < Que::Job
|
class DomainUpdateConfirmJob < Que::Job
|
||||||
def run(domain_id, action)
|
def run(domain_id, action)
|
||||||
# it's recommended to keep transaction against job table as short as possible.
|
# it's recommended to keep transaction against job table as short as possible.
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
|
@ -390,6 +390,15 @@ class Epp::Domain < Domain
|
||||||
clean_pendings! if update(frame, user, false)
|
clean_pendings! if update(frame, user, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apply_pending_delete!
|
||||||
|
preclean_pendings
|
||||||
|
user = ApiUser.find(pending_json['current_user_id'])
|
||||||
|
frame = Nokogiri::XML(pending_json['frame'])
|
||||||
|
statuses.delete(DomainStatus::PENDING_DELETE)
|
||||||
|
|
||||||
|
clean_pendings! if epp_destroy(frame, user, false)
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -399,10 +408,10 @@ class Epp::Domain < Domain
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def epp_destroy(frame, user_id)
|
def epp_destroy(frame, user_id, verify=true)
|
||||||
return false unless valid?
|
return false unless valid?
|
||||||
|
|
||||||
if frame.css('delete').attr('verified').to_s.downcase != 'yes'
|
if verify && frame.css('delete').attr('verified').to_s.downcase != 'yes'
|
||||||
registrant_verification_asked!(frame.to_s, user_id)
|
registrant_verification_asked!(frame.to_s, user_id)
|
||||||
self.deliver_emails = true # turn on email delivery for epp
|
self.deliver_emails = true # turn on email delivery for epp
|
||||||
pending_delete!
|
pending_delete!
|
||||||
|
|
|
@ -17,12 +17,24 @@ 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
|
||||||
DomainConfirmJob.enqueue domain.id, CONFIRMED if save
|
DomainUpdateConfirmJob.enqueue domain.id, CONFIRMED if save
|
||||||
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
|
||||||
DomainConfirmJob.enqueue domain.id, REJECTED if save
|
DomainUpdateConfirmJob.enqueue domain.id, REJECTED if save
|
||||||
|
end
|
||||||
|
|
||||||
|
def domain_registrant_delete_confirm!
|
||||||
|
self.action_type = DOMAIN_DELETE
|
||||||
|
self.action = CONFIRMED
|
||||||
|
DomainDeleteConfirmJob.enqueue domain.id, CONFIRMED if save
|
||||||
|
end
|
||||||
|
|
||||||
|
def domain_registrant_delete_reject!
|
||||||
|
self.action_type = DOMAIN_DELETE
|
||||||
|
self.action = REJECTED
|
||||||
|
DomainDeleteConfirmJob.enqueue domain.id, REJECTED if save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,44 @@
|
||||||
- if @domain.present?
|
- if params[:confirmed].present?
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%h1= t(:domain_delete_confirmed_title)
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%p= t(:domain_delete_confirmed_body)
|
||||||
|
- elsif params[:rejected].present?
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%h1= t(:domain_delete_rejected_title)
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%p= t(:domain_delete_rejected_body)
|
||||||
- else
|
- else
|
||||||
%h1= t(:not_valid_domain_verification_title).html_safe
|
- if @domain.present?
|
||||||
%p= t(:not_valid_domain_verification_body).html_safe
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%h1= t(:domain_delete_title)
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%p= t(:domain_delete_body)
|
||||||
|
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-12.text-center.confirmation
|
||||||
|
.column-keys
|
||||||
|
%p= t(:domain_name) + ':'
|
||||||
|
%p= t(:registrant) + ':'
|
||||||
|
.column-values
|
||||||
|
%p= @domain.name
|
||||||
|
%p= "#{@domain.registrant_name} (#{@domain.registrant.ident})"
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12.text-center
|
||||||
|
.confirmation
|
||||||
|
= form_for registrant_domain_delete_confirm_path(@domain.id), method: :patch do |f|
|
||||||
|
= hidden_field_tag :token, params[:token]
|
||||||
|
= f.button t(:confirm_domain_delete), name: 'confirmed', class: 'btn btn-primary'
|
||||||
|
= f.button t(:reject_domain_delete), name: 'rejected', class: 'btn btn-warning'
|
||||||
|
%hr
|
||||||
|
- else
|
||||||
|
%h1= t(:not_valid_domain_verification_title).html_safe
|
||||||
|
%p= t(:not_valid_domain_verification_body).html_safe
|
||||||
|
|
|
@ -793,14 +793,20 @@ en:
|
||||||
new_pending_registrant: 'New registrant'
|
new_pending_registrant: 'New registrant'
|
||||||
current_registrant: 'Current registrant'
|
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 received'
|
||||||
domain_registrant_change_confirmed_body: 'You have successfully confirmed domain owner change.'
|
domain_registrant_change_confirmed_body: 'You have successfully submitted domain owner change confirmation. You will receive email confirmation.'
|
||||||
registrant_domain_verification_confirmed: 'Domain owner change has successfully confirmed.'
|
registrant_domain_verification_confirmed: 'Domain owner change has successfully received.'
|
||||||
registrant_domain_verification_confirmed_failed: 'Something went wrong'
|
registrant_domain_verification_confirmed_failed: 'Something went wrong.'
|
||||||
domain_registrant_change_rejected_title: 'Domain owner change has been rejected'
|
domain_registrant_change_rejected_title: 'Domain owner change has been rejected'
|
||||||
domain_registrant_change_rejected_body: 'You have rejected domain owner change.'
|
domain_registrant_change_rejected_body: 'You have rejected domain owner change.'
|
||||||
registrant_domain_verification_rejected: 'Domain owner change has been rejected successfully.'
|
registrant_domain_verification_rejected: 'Domain owner change has been rejected successfully.'
|
||||||
registrant_domain_verification_rejected_failed: 'Something went wrong'
|
registrant_domain_verification_rejected_failed: 'Something went wrong.'
|
||||||
|
domain_delete_title: 'Please confirm or reject domain deletation'
|
||||||
|
domain_delete_body: 'There is a request to delete a domain. Before doing it we need your confirmation.'
|
||||||
|
domain_delete_confirmed_title: 'Domain deletion has been received successfully'
|
||||||
|
domain_delete_confirmed_body: 'You have successfully submitted delete confirmation. You will receive registry final confirmation to email.'
|
||||||
|
domain_delete_rejected_title: 'Domain deletion has been rejected successfully'
|
||||||
|
domain_delete_rejected_body: 'You have rejected domain deletion.'
|
||||||
ip_is_not_whitelisted: 'IP is not whitelisted'
|
ip_is_not_whitelisted: 'IP is not whitelisted'
|
||||||
no_permission: 'No permission'
|
no_permission: 'No permission'
|
||||||
access_denied: 'Access denied'
|
access_denied: 'Access denied'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue