Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/concerns/two_factor_authenticatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def after_otp_action_path
elsif @updating_existing_number
account_path
elsif decorated_user.password_reset_profile.present?
reactivate_profile_path
reactivate_account_path
else
account_path
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sign_up/personal_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def next_step
if session[:sp]
sign_up_completed_path
elsif current_user.decorate.password_reset_profile.present?
reactivate_profile_path
reactivate_account_path
else
after_sign_in_path_for(current_user)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/personal_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update

def next_step
if current_user.decorate.password_reset_profile.present?
reactivate_profile_url
reactivate_account_url
else
account_url
end
Expand Down
25 changes: 25 additions & 0 deletions app/controllers/users/reactivate_account_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Users
class ReactivateAccountController < ApplicationController
def index
@reactivate_account_form = ReactivateAccountForm.new(current_user)
end

def create
@reactivate_account_form = build_reactivate_account_form
if @reactivate_account_form.submit(flash)
redirect_to account_path
else
render :index
end
end

protected

def build_reactivate_account_form
ReactivateAccountForm.new(
current_user,
params[:reactivate_account_form].permit(:password, :personal_key)
)
end
end
end
25 changes: 0 additions & 25 deletions app/controllers/users/reactivate_profile_controller.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module Users
class VerifyProfileController < ApplicationController
class VerifyAccountController < ApplicationController
before_action :confirm_verification_needed

def index
@verify_profile_form = VerifyProfileForm.new(user: current_user)
@verify_account_form = VerifyAccountForm.new(user: current_user)
end

def create
@verify_profile_form = build_verify_profile_form
if @verify_profile_form.submit
@verify_account_form = build_verify_account_form
if @verify_account_form.submit
flash[:success] = t('account.index.verification.success')
redirect_to account_path
else
Expand All @@ -18,16 +18,16 @@ def create

private

def build_verify_profile_form
VerifyProfileForm.new(
def build_verify_account_form
VerifyAccountForm.new(
user: current_user,
otp: params_otp,
pii_attributes: decrypted_pii
)
end

def params_otp
params[:verify_profile_form].permit(:otp)[:otp]
params[:verify_account_form].permit(:otp)[:otp]
end

def confirm_verification_needed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ReactivateProfileForm
class ReactivateAccountForm
include ActiveModel::Model
include PersonalKeyValidator

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class VerifyProfileForm
class VerifyAccountForm
include ActiveModel::Model

validates :otp, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/_password_reset.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.mb4.alert.alert-warning
p = t('account.index.reactivation.instructions')
p.mb0 = link_to t('account.index.reactivation.reactivate_button'), reactivate_profile_path
p.mb0 = link_to t('account.index.reactivation.reactivate_button'), reactivate_account_path
2 changes: 1 addition & 1 deletion app/views/accounts/_pending_profile.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.mb4.alert.alert-warning
p = t('account.index.verification.instructions')
p.mb0 = link_to t('account.index.verification.reactivate_button'), verify_profile_path
p.mb0 = link_to t('account.index.verification.reactivate_button'), verify_account_path
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

h1.h3.my0 = t('forms.reactivate_profile.title')
p.mt-tiny.mb0 = t('forms.reactivate_profile.instructions')
= simple_form_for(@reactivate_profile_form, url: reactivate_profile_path,
= simple_form_for(@reactivate_account_form, url: reactivate_account_path,
html: { autocomplete: 'off', method: :post, role: 'form' }) do |f|
= f.error :base
= render 'partials/personal_key/entry_fields', f: f, attribute_name: :personal_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

h1.h3.my0 = t('forms.verify_profile.title')
p.mt-tiny.mb0 = t('forms.verify_profile.instructions')
= simple_form_for(@verify_profile_form, url: verify_profile_path,
= simple_form_for(@verify_account_form, url: verify_account_path,
html: { autocomplete: 'off', method: :post, role: 'form' }) do |f|
= f.error :base
= f.input :otp, required: true, label: 'Secret code'
Expand Down
10 changes: 6 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
as: :openid_connect_configuration

get '/account' => 'accounts#show'
get '/account/reactivate' => 'users/reactivate_account#index', as: :reactivate_account
post '/account/reactivate' => 'users/reactivate_account#create'
get '/account/verify' => 'users/verify_account#index', as: :verify_account
post '/account/verify' => 'users/verify_account#create'

get '/api/health/workers' => 'health/workers#index'
get '/api/openid_connect/certs' => 'openid_connect/certs#index'
Expand Down Expand Up @@ -88,10 +92,8 @@
as: :user_two_factor_authentication # route name is used by two_factor_authentication gem

get '/profile', to: redirect('/account')
get '/profile/reactivate' => 'users/reactivate_profile#index', as: :reactivate_profile
post '/profile/reactivate' => 'users/reactivate_profile#create'
get '/profile/verify' => 'users/verify_profile#index', as: :verify_profile
post '/profile/verify' => 'users/verify_profile#create'
get '/profile/reactivate', to: redirect('/account/reactivate')
get '/profile/verify', to: redirect('/account/verify')

post '/sign_up/create_password' => 'sign_up/passwords#create', as: :sign_up_create_password
get '/sign_up/email/confirm' => 'sign_up/email_confirmations#create',
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/users/personal_keys_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

patch :update

expect(response).to redirect_to reactivate_profile_url
expect(response).to redirect_to reactivate_account_url
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'rails_helper'

RSpec.describe Users::ReactivateProfileController do
RSpec.describe Users::ReactivateAccountController do
include Features::LocalizationHelper

describe '#create' do
subject(:action) do
post(
:create,
reactivate_profile_form: {
reactivate_account_form: {
password: 'password',
personal_key: 'personal_key',
}
Expand All @@ -17,8 +17,8 @@
before do
stub_sign_in

form = instance_double('ReactivateProfileForm', submit: success)
expect(controller).to receive(:build_reactivate_profile_form).and_return(form)
form = instance_double('ReactivateAccountForm', submit: success)
expect(controller).to receive(:build_reactivate_account_form).and_return(form)
end

context 'with a valid form' do
Expand All @@ -37,7 +37,7 @@
it 'renders the index page to show errors' do
action

expect(response).to render_template('users/reactivate_profile/index')
expect(response).to render_template('users/reactivate_account/index')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'rails_helper'

RSpec.describe Users::VerifyProfileController do
RSpec.describe Users::VerifyAccountController do
include Features::LocalizationHelper

describe '#create' do
subject(:action) do
post(
:create,
verify_profile_form: {
verify_account_form: {
otp: 'abc123',
}
)
Expand All @@ -16,8 +16,8 @@
before do
stub_sign_in

form = instance_double('VerifyProfileForm', submit: success)
expect(controller).to receive(:build_verify_profile_form).and_return(form)
form = instance_double('VerifyAccountForm', submit: success)
expect(controller).to receive(:build_verify_account_form).and_return(form)
end

context 'with a valid form' do
Expand All @@ -36,7 +36,7 @@
it 'renders the index page to show errors' do
action

expect(response).to render_template('users/verify_profile/index')
expect(response).to render_template('users/verify_account/index')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
click_submit_default
enter_correct_otp_code_for_user(user)

expect(current_path).to eq reactivate_profile_path
expect(current_path).to eq reactivate_account_path

reactivate_profile(new_password, personal_key)

Expand All @@ -32,14 +32,14 @@
click_submit_default
enter_correct_otp_code_for_user(user)

expect(current_path).to eq reactivate_profile_path
expect(current_path).to eq reactivate_account_path

visit manage_personal_key_path

new_personal_key = scrape_personal_key
click_acknowledge_personal_key

expect(current_path).to eq reactivate_profile_path
expect(current_path).to eq reactivate_account_path

reactivate_profile(new_password, new_personal_key)

Expand All @@ -65,7 +65,7 @@
new_personal_key = scrape_personal_key
click_acknowledge_personal_key

expect(current_path).to eq reactivate_profile_path
expect(current_path).to eq reactivate_account_path

reactivate_profile(new_password, new_personal_key)

Expand Down
4 changes: 2 additions & 2 deletions spec/features/users/verify_profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

click_on t('account.index.verification.reactivate_button')

expect(current_path).to eq verify_profile_path
expect(current_path).to eq verify_account_path

fill_in 'Secret code', with: otp
click_button t('forms.verify_profile.submit')
Expand All @@ -41,7 +41,7 @@
fill_in 'Secret code', with: 'the wrong code'
click_button t('forms.verify_profile.submit')

expect(current_path).to eq verify_profile_path
expect(current_path).to eq verify_account_path
expect(page).to have_content(t('errors.messages.otp_incorrect'))
expect(page.body).to_not match('the wrong code')
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rails_helper'

describe ReactivateProfileForm do
describe ReactivateAccountForm do
subject(:form) do
ReactivateProfileForm.new(user,
ReactivateAccountForm.new(user,
password: password)
end

Expand Down Expand Up @@ -45,7 +45,7 @@

context 'when personal key does not match' do
subject(:form) do
ReactivateProfileForm.new(user,
ReactivateAccountForm.new(user,
personal_key: personal_key,
password: password)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rails_helper'

describe VerifyProfileForm do
describe VerifyAccountForm do
subject(:form) do
VerifyProfileForm.new(user: user, otp: otp, pii_attributes: pii_attributes)
VerifyAccountForm.new(user: user, otp: otp, pii_attributes: pii_attributes)
end

let(:user) { pending_profile.user }
Expand Down
16 changes: 16 additions & 0 deletions spec/requests/redirects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@
expect(response).to redirect_to('/account')
end
end

describe '/profile/reactivate' do
it 'redirects to /account/reactivate' do
get '/profile/reactivate'

expect(response).to redirect_to('/account/reactivate')
end
end

describe '/profile/verify' do
it 'redirects to /account/verify' do
get '/profile/verify'

expect(response).to redirect_to('/account/verify')
end
end
end
4 changes: 2 additions & 2 deletions spec/views/accounts/show.html.slim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
render

expect(rendered).to_not have_link(
t('account.index.verification.reactivate_button'), href: verify_profile_path
t('account.index.verification.reactivate_button'), href: verify_account_path
)
end
end
Expand All @@ -107,7 +107,7 @@
render

expect(rendered).
to have_link(t('account.index.verification.reactivate_button'), href: verify_profile_path)
to have_link(t('account.index.verification.reactivate_button'), href: verify_account_path)
end
end

Expand Down