From 4f8f08ecc9c2354a45747837fade46b5957521dd Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 2 Dec 2015 13:49:44 +0200 Subject: [PATCH 01/12] Story #109086524 - force is_admin to skip validation until validations can be fixed --- app/controllers/admin/pending_updates_controller.rb | 2 ++ app/models/epp/domain.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 4d08297d7..3a15fb3a5 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -6,6 +6,8 @@ class Admin::PendingUpdatesController < AdminController authorize! :update, :pending @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending + @epp_domain.is_admin = true + if @epp_domain.apply_pending_update! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 613c57115..4d86e7e15 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -4,6 +4,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions + return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 80fe0428b213b24fa7844ef69327effd6e52c4fc Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 2 Dec 2015 13:49:44 +0200 Subject: [PATCH 02/12] Story #109086524 - force is_admin to skip validation until validations can be fixed --- app/controllers/admin/pending_updates_controller.rb | 2 ++ app/models/epp/domain.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 4d08297d7..3a15fb3a5 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -6,6 +6,8 @@ class Admin::PendingUpdatesController < AdminController authorize! :update, :pending @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending + @epp_domain.is_admin = true + if @epp_domain.apply_pending_update! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 739c55bec..3471cf131 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,6 +7,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions + return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 05b2408b430c0123c995ab90c59f7311cfd03c63 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:06:52 +0200 Subject: [PATCH 03/12] Story #109086524 - Save update with the user id that requested update, when admin approves (I thought this change was already committed, but where?) --- app/models/epp/domain.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 3471cf131..5468f9678 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -507,7 +507,9 @@ class Epp::Domain < Domain frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here + save + PaperTrail.whodunnit = user return unless update(frame, user, false) clean_pendings! self.deliver_emails = true # turn on email delivery From 32d0200a9f1887f757db5d6784c7ae4486796217 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:09:43 +0200 Subject: [PATCH 04/12] Story #109086524 - change execution path, admin will now use same method as registrant to apply pending update This change now include creating registrar message --- .../admin/pending_updates_controller.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 3a15fb3a5..6e41a6c57 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -5,10 +5,7 @@ class Admin::PendingUpdatesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - @epp_domain.is_admin = true - - if @epp_domain.apply_pending_update! + if registrant_verification.domain_registrant_change_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to edit_admin_domain_path(@domain.id), alert: t(:failure) @@ -17,14 +14,21 @@ class Admin::PendingUpdatesController < AdminController def destroy authorize! :destroy, :pending - - if @domain.clean_pendings! + if registrant_verification.domain_registrant_change_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) end end + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + private def find_domain From 176bd33ad585a1560a05b3edfbafbc2262c31836 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:13:27 +0200 Subject: [PATCH 05/12] Story #109086524 - remove excess method call --- app/jobs/domain_update_confirm_job.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 28294ef25..bc4beb541 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -9,7 +9,6 @@ class DomainUpdateConfirmJob < Que::Job domain.apply_pending_update! do |e| e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) end - domain.clean_pendings! when RegistrantVerification::REJECTED DomainMailer.pending_update_rejected_notification_for_new_registrant(domain_id).deliver domain.poll_message!(:poll_pending_update_rejected_by_registrant) From 6c90d5825b395783e4f61416fa30cf530d90bce5 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:45:54 +0200 Subject: [PATCH 06/12] Story #109086524 - revert to allow merge, changes fixed on branch for story 109367694 --- app/models/epp/domain.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 5468f9678..739c55bec 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,7 +7,6 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions - return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false @@ -507,9 +506,7 @@ class Epp::Domain < Domain frame = Nokogiri::XML(pending_json['frame']) statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here - save - PaperTrail.whodunnit = user return unless update(frame, user, false) clean_pendings! self.deliver_emails = true # turn on email delivery From db870574c2b853729ab5caaba66f697510d52b5b Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 2 Dec 2015 13:49:44 +0200 Subject: [PATCH 07/12] Story #109086524 - force is_admin to skip validation until validations can be fixed --- app/controllers/admin/pending_updates_controller.rb | 2 ++ app/models/epp/domain.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 4d08297d7..3a15fb3a5 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -6,6 +6,8 @@ class Admin::PendingUpdatesController < AdminController authorize! :update, :pending @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending + @epp_domain.is_admin = true + if @epp_domain.apply_pending_update! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 40b374003..3e5b842b2 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,6 +7,7 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions + return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 226e82c71a6e15ca0cdb9375853a44695d93edd8 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:09:43 +0200 Subject: [PATCH 08/12] Story #109086524 - change execution path, admin will now use same method as registrant to apply pending update This change now include creating registrar message --- .../admin/pending_updates_controller.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 3a15fb3a5..6e41a6c57 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -5,10 +5,7 @@ class Admin::PendingUpdatesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - @epp_domain.is_admin = true - - if @epp_domain.apply_pending_update! + if registrant_verification.domain_registrant_change_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to edit_admin_domain_path(@domain.id), alert: t(:failure) @@ -17,14 +14,21 @@ class Admin::PendingUpdatesController < AdminController def destroy authorize! :destroy, :pending - - if @domain.clean_pendings! + if registrant_verification.domain_registrant_change_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) end end + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + private def find_domain From 611151317c92ed0648c92a9fe9592e112a3ce5e1 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Sun, 13 Dec 2015 13:13:27 +0200 Subject: [PATCH 09/12] Story #109086524 - remove excess method call --- app/jobs/domain_update_confirm_job.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 28294ef25..bc4beb541 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -9,7 +9,6 @@ class DomainUpdateConfirmJob < Que::Job domain.apply_pending_update! do |e| e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) end - domain.clean_pendings! when RegistrantVerification::REJECTED DomainMailer.pending_update_rejected_notification_for_new_registrant(domain_id).deliver domain.poll_message!(:poll_pending_update_rejected_by_registrant) From 674fa9f76b8bee9ab3770ac981a34ad888f2f9f2 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Mon, 14 Dec 2015 11:45:54 +0200 Subject: [PATCH 10/12] Story #109086524 - revert to allow merge, changes fixed on branch for story 109367694 --- app/models/epp/domain.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 3e5b842b2..40b374003 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -7,7 +7,6 @@ class Epp::Domain < Domain before_validation :manage_permissions def manage_permissions - return if is_admin # this bad hack for 109086524, refactor later return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false From 250cda0923a5edece645cd5936bc325f0207c5eb Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 17:12:13 +0200 Subject: [PATCH 11/12] Story #109086524 - change code path for pendingDelete to send registrar method --- .../admin/pending_deletes_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/pending_deletes_controller.rb b/app/controllers/admin/pending_deletes_controller.rb index a64a34714..2eda703bd 100644 --- a/app/controllers/admin/pending_deletes_controller.rb +++ b/app/controllers/admin/pending_deletes_controller.rb @@ -5,9 +5,7 @@ class Admin::PendingDeletesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - @epp_domain.is_admin= true - if @epp_domain.apply_pending_delete! + if registrant_verification.domain_registrant_delete_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure) @@ -17,7 +15,7 @@ class Admin::PendingDeletesController < AdminController def destroy authorize! :destroy, :pending - if @domain.clean_pendings! + if registrant_verification.domain_registrant_delete_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) @@ -26,6 +24,14 @@ class Admin::PendingDeletesController < AdminController private + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + def find_domain @domain = Domain.find(params[:domain_id]) end From da410aaa1f93590eb80ea9b1a179237d52ac44c1 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Thu, 17 Dec 2015 19:55:09 +0200 Subject: [PATCH 12/12] Story #109367018 - remove validation that token domain and token are unique, prevents required action for delete reject --- app/models/registrant_verification.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/registrant_verification.rb b/app/models/registrant_verification.rb index d0c015ecb..a33751413 100644 --- a/app/models/registrant_verification.rb +++ b/app/models/registrant_verification.rb @@ -12,7 +12,6 @@ class RegistrantVerification < ActiveRecord::Base belongs_to :domain validates :verification_token, :domain_name, :domain, :action, :action_type, presence: true - validates :domain, uniqueness: { scope: [:domain_id, :verification_token] } def domain_registrant_change_confirm! self.action_type = DOMAIN_REGISTRANT_CHANGE