Disallow EPP domain:update/transfer/delete if a domain has "deleteCandidate" status

#355
This commit is contained in:
Artur Beljajev 2017-01-24 19:16:15 +02:00
parent d4ddb5dc25
commit edf1e33260
10 changed files with 193 additions and 2 deletions

View file

@ -0,0 +1,11 @@
module Concerns::Domain::Deletable
extend ActiveSupport::Concern
included do
alias_attribute :delete_time, :delete_at
end
def discarded?
statuses.include?(DomainStatus::DELETE_CANDIDATE)
end
end

View file

@ -5,6 +5,7 @@ class Domain < ActiveRecord::Base
include Concerns::Domain::Expirable
include Concerns::Domain::Activatable
include Concerns::Domain::ForceDelete
include Concerns::Domain::Deletable
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
@ -14,7 +15,6 @@ class Domain < ActiveRecord::Base
alias_attribute :on_hold_time, :outzone_at
alias_attribute :outzone_time, :outzone_at
alias_attribute :delete_time, :delete_at
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
# TODO: most inputs should be trimmed before validatation, probably some global logic?

View file

@ -472,6 +472,9 @@ class Epp::Domain < Domain
# rubocop: disable Metrics/CyclomaticComplexity
def update(frame, current_user, verify = true)
return super if frame.blank?
check_discarded
at = {}.with_indifferent_access
at.deep_merge!(attrs_from(frame.css('chg'), current_user, 'chg'))
at.deep_merge!(attrs_from(frame.css('rem'), current_user, 'rem'))
@ -563,6 +566,8 @@ class Epp::Domain < Domain
def epp_destroy(frame, user_id)
return false unless valid?
check_discarded
if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame))
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
end
@ -629,6 +634,8 @@ class Epp::Domain < Domain
# rubocop: disable Metrics/CyclomaticComplexity
def transfer(frame, action, current_user)
check_discarded
@is_transfer = true
case action
@ -925,5 +932,16 @@ class Epp::Domain < Domain
res
end
end
private
def check_discarded
if discarded?
throw :epp_error, {
code: '2105',
msg: I18n.t(:object_is_not_eligible_for_renewal),
}
end
end
end
# rubocop: enable Metrics/ClassLength