diff --git a/app/controllers/registrant/domain_update_confirms_controller.rb b/app/controllers/registrant/domain_update_confirms_controller.rb
new file mode 100644
index 000000000..f02d3e97b
--- /dev/null
+++ b/app/controllers/registrant/domain_update_confirms_controller.rb
@@ -0,0 +1,16 @@
+class Registrant::DomainUpdateConfirmsController < RegistrantController
+ skip_before_action :authenticate_user!, only: [:show, :create]
+ skip_authorization_check only: [:show, :create]
+
+ def show
+ @domain = Domain.find(params[:id])
+
+ if @domain.present? && params[:token].present? && @domain.registrant_verification_token == params[:token]
+ else
+ @domain = nil
+ end
+ end
+
+ def create
+ end
+end
diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb
index 937ff3a4e..131018672 100644
--- a/app/mailers/domain_mailer.rb
+++ b/app/mailers/domain_mailer.rb
@@ -10,7 +10,9 @@ class DomainMailer < ApplicationMailer
end
@old_registrant = Registrant.find(@domain.registrant_id_was)
- @verification_url = "#{ENV['registrant_url']}/etc/"
+
+ confirm_path = "#{ENV['registrant_url']}/registrant/domain_update_confirms"
+ @verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
mail(to: @old_registrant.email,
subject: "#{I18n.t(:domain_registrant_update_subject, name: @domain.name)} [#{@domain.name}]")
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 097f09020..84be67c3a 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -18,7 +18,9 @@ class Ability
registrant
end
+ # Public user
can :show, :dashboard
+ can :create, :registrant_domain_update_confirm
end
# rubocop: disable Metrics/CyclomaticComplexity
@@ -67,7 +69,7 @@ class Ability
end
def registrant
- can :manage, Registrant::Whois
+ can :manage, :registrant_whois
can :manage, Depp::Domain
end
diff --git a/app/views/domain_mailer/registrant_updated.html.erb b/app/views/domain_mailer/registrant_updated.html.erb
index 72115fddb..b081bf2b4 100644
--- a/app/views/domain_mailer/registrant_updated.html.erb
+++ b/app/views/domain_mailer/registrant_updated.html.erb
@@ -16,7 +16,7 @@ Linn: <%= @domain.registrant_city %>
Riik: <%= @domain.registrant_country %>
Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
-<%= @verification_url %>
+<%= link_to @verification_url, @verification_url %>
Lugupidamisega
Eesti Interneti SA
@@ -41,7 +41,7 @@ City: <%= @domain.registrant_city %>
Country: <%= @domain.registrant_country %>
To confirm the update please visit this website, once again review the data and press approve:
-<%= @verification_url %>
+<%= link_to @verification_url, @verification_url %>
Best Regards,
Estonian Internet Foundation
diff --git a/app/views/registrant/domain_update_confirms/show.haml b/app/views/registrant/domain_update_confirms/show.haml
new file mode 100644
index 000000000..ee495fa38
--- /dev/null
+++ b/app/views/registrant/domain_update_confirms/show.haml
@@ -0,0 +1,2 @@
+- if @domain.blank?
+ %h1= t(:not_valid_domain_verification)
diff --git a/config/locales/en.yml b/config/locales/en.yml
index bcab7ee6c..c739fd53e 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -768,3 +768,4 @@ en:
domain_registrant_update_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant chache of %{name}"
whois: WHOIS
login_failed_check_id_card: 'Log in failed, check ID card'
+ not_valid_domain_verification: Not valid domain update verification
diff --git a/config/routes.rb b/config/routes.rb
index 04c63fd9c..d46d3f2b7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -103,6 +103,8 @@ Rails.application.routes.draw do
# resources :deposits
# resources :account_activities
+ resources :domain_update_confirms
+
devise_scope :user do
get 'login' => 'sessions#login'
get 'login/mid' => 'sessions#login_mid'
diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb
index 3fcffa1dc..bdf0f1e2a 100644
--- a/spec/mailers/domain_mailer_spec.rb
+++ b/spec/mailers/domain_mailer_spec.rb
@@ -31,10 +31,7 @@ describe DomainMailer do
@new_registrant = Fabricate(:registrant, email: 'test@example.org')
@domain = Fabricate(:domain, registrant: @registrant)
@domain.deliver_emails = true
-<<<<<<< HEAD
-=======
@domain.registrant_verification_token = '123'
->>>>>>> 0ddd2b6f32fa7e9abec8b2e7c88173585a78f3dd
@domain.registrant = @new_registrant
@mail = DomainMailer.registrant_updated(@domain)
end
@@ -54,5 +51,9 @@ describe DomainMailer do
it 'should render body' do
@mail.body.encoded.should =~ /Registrisse laekus taotlus domeeni/
end
+
+ it 'should render verification url' do
+ @mail.body.encoded.should =~ /registrant\/domain_update_confirms/
+ end
end
end