Refactor confirmation url view in registrant area

This commit is contained in:
Artur Beljajev 2019-04-06 19:00:55 +03:00
parent aad39fd2b7
commit 1dfc618228
7 changed files with 32 additions and 20 deletions

View file

@ -16,19 +16,19 @@ class Registrant::DomainsController < RegistrantController
authorize! :read, @domain
end
def domain_verification_url
def confirmation
authorize! :view, :registrant_domains
dom = current_user_domains.find(params[:id])
if (dom.statuses.include?(DomainStatus::PENDING_UPDATE) || dom.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
dom.pending_json.present?
domain = current_user_domains.find(params[:id])
@domain = dom
confirm_path = get_confirm_path(dom.statuses)
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
if (domain.statuses.include?(DomainStatus::PENDING_UPDATE) ||
domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
domain.pending_json.present?
@domain = domain
@confirmation_url = confirmation_url(domain)
else
flash[:warning] = I18n.t('available_verification_url_not_found')
redirect_to registrant_domain_path(dom.id)
redirect_to registrant_domain_path(domain)
end
end
@ -63,11 +63,11 @@ class Registrant::DomainsController < RegistrantController
params[:q][:valid_to_lteq] = ca_cache
end
def get_confirm_path(statuses)
if statuses.include?(DomainStatus::PENDING_UPDATE)
"#{ENV['registrant_url']}/registrant/domain_update_confirms"
elsif statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)
"#{ENV['registrant_url']}/registrant/domain_delete_confirms"
def confirmation_url(domain)
if domain.statuses.include?(DomainStatus::PENDING_UPDATE)
registrant_domain_update_confirm_url(token: domain.registrant_verification_token)
elsif domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)
registrant_domain_delete_confirm_url(token: domain.registrant_verification_token)
end
end
end
end

View file

@ -5,9 +5,9 @@
.col-md-12
.panel.panel-default
.panel-heading
%h3.panel-title= t(:personal_domain_verification_url)
%h3.panel-title= t('.header')
.panel-body
.input-group.input-group-lg
%span#sizing-addon1.input-group-addon.glyphicon.glyphicon-link
%input.form-control{"aria-describedby" => "sizing-addon1", type: "text", value: @verification_url}
%input.form-control{"aria-describedby" => "sizing-addon1", type: "text", value: @confirmation_url}

View file

@ -12,7 +12,7 @@
%tr
%td
- if [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION].include?(status) && @domain.pending_json.present?
= link_to(status, domain_verification_url_registrant_domain_url(@domain.id))
= link_to(status, confirmation_registrant_domain_path(@domain))
- else
= status
%td= @domain.status_notes[status]