Merge branch 'master' of github.com:domify/registry

Conflicts:
	config/locales/en.yml
	db/schema.rb
This commit is contained in:
Martin Lensment 2015-05-19 17:26:32 +03:00
commit 2fb632b7a9
21 changed files with 298 additions and 54 deletions

View file

@ -181,11 +181,16 @@ class Domain < ActiveRecord::Base
return true unless registrant_verification_asked?
pending_json_cache = all_changes
token = registrant_verification_token
asked_at = registrant_verification_asked_at
DomainMailer.registrant_pending_updated(self).deliver_now
reload # revert back to original
self.pending_json = pending_json_cache
self.registrant_verification_token = token
self.registrant_verification_asked_at = asked_at
domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
end
@ -198,6 +203,15 @@ class Domain < ActiveRecord::Base
true
end
def registrant_delete_confirmable?(token)
return false unless pending_delete?
return false if registrant_verification_token.blank?
return false if registrant_verification_asked_at.blank?
return false if token.blank?
return false if registrant_verification_token != token
true
end
def registrant_verification_asked?
registrant_verification_asked_at.present? && registrant_verification_token.present?
end
@ -275,6 +289,15 @@ class Domain < ActiveRecord::Base
name
end
def pending_registrant_name
return '' if pending_json.blank?
return '' if pending_json['domain'].blank?
return '' if pending_json['domain']['registrant_id'].blank?
registrant = Registrant.find_by(id: pending_json['domain']['registrant_id'].last)
registrant.try(:name)
end
# rubocop:disable Lint/Loop
def generate_auth_info
begin

View file

@ -1,5 +1,28 @@
# Used in Registrant portal to collect registrant verifications
# Registrant postgres user can access this table directly.
class RegistrantVerification < ActiveRecord::Base
validates :verification_token, :domain_name, presence: true
# actions
CONFIRMED = 'confirmed'
REJECTED = 'rejected'
# action types
DOMAIN_REGISTRANT_CHANGE = 'domain_registrant_change'
DOMAIN_DELETE = 'domain_delete'
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
self.action = CONFIRMED
save
end
def domain_registrant_change_reject!
self.action_type = DOMAIN_REGISTRANT_CHANGE
self.action = REJECTED
save
end
end