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
1 change: 1 addition & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class AccountsController < ApplicationController
include RememberDeviceConcern
before_action :confirm_two_factor_authenticated
before_action :confirm_user_is_not_suspended

layout 'account_side_nav'

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def after_sign_in_path_for(_user)

def signed_in_url
return user_two_factor_authentication_url unless user_fully_authenticated?
return user_please_call_url if current_user.suspended?
return reactivate_account_url if user_needs_to_reactivate_account?
return url_for_pending_profile_reason if user_has_pending_profile?
return backup_code_reminder_url if user_needs_backup_code_reminder?
Expand Down Expand Up @@ -295,6 +296,10 @@ def reauthn?
reauthn.present? && reauthn == 'true'
end

def confirm_user_is_not_suspended
redirect_to user_please_call_url if current_user.suspended?
end

def confirm_two_factor_authenticated
authenticate_user!(force: true)

Expand Down
9 changes: 9 additions & 0 deletions app/controllers/users/please_call_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Users
class PleaseCallController < ApplicationController
before_action :confirm_two_factor_authenticated

def show
analytics.user_suspended_please_call_visited
end
end
end
8 changes: 8 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3892,6 +3892,14 @@ def user_suspended(
)
end

# Tracks when the user is suspended and attempts to sign in, triggering the please call page.
def user_suspended_please_call_visited(**extra)
track_event(
'User Suspension: Please call visited',
**extra,
)
end

# Tracks when USPS in-person proofing enrollment is created
# @param [String] enrollment_code
# @param [Integer] enrollment_id
Expand Down
11 changes: 11 additions & 0 deletions app/views/users/please_call/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%= render(
'idv/shared/error',
heading: t('users.suspended_sign_in_account.heading'),
) do %>
<p>
<%= t('users.suspended_sign_in_account.contact_details', contact_number: IdentityConfig.store.idv_contact_phone_number) %>
</p>
<p>
<%= t('users.suspended_sign_in_account.error_details', error_code: IdentityConfig.store.account_suspended_support_code) %>
</p>
<% end %>
5 changes: 5 additions & 0 deletions config/locales/users/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ en:
</ul>
overview_html: We’ve updated our %{link_html}. Please review and check the box
below to continue.
suspended_sign_in_account:
contact_details: We couldn’t sign you in. Please call our contact center at
%{contact_number}.
error_details: Please provide the error code %{error_code}.
heading: Please give us a call
5 changes: 5 additions & 0 deletions config/locales/users/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ es:
</ul>
overview_html: Actualizamos nuestro %{link_html}. Revise y marque la casilla a
continuación para continuar.
suspended_sign_in_account:
contact_details: No pudimos iniciar tu sesión. Por favor, llama a nuestro centro
de contacto al %{contact_number}.
error_details: Proporciona el código de error %{error_code}.
heading: Llámenos
5 changes: 5 additions & 0 deletions config/locales/users/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ fr:
</ul>
overview_html: Nous avons mis à jour notre %{link_html}. Veuillez consulter et
cocher la case ci-dessous pour continuer.
suspended_sign_in_account:
contact_details: Nous n’avons pas pu vous connecter. Merci d’appeler notre
centre de contact au %{contact_number}.
error_details: Indiquez le code d’erreur %{error_code}.
heading: S’il vous plaît, appelez-nous
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@

get '/piv_cac_delete' => 'users/piv_cac_setup#confirm_delete'
get '/auth_app_delete' => 'users/totp_setup#confirm_delete'
get '/user_please_call' => 'users/please_call#show'

get '/profile', to: redirect('/account')
get '/profile/reactivate', to: redirect('/account/reactivate')
Expand Down
20 changes: 20 additions & 0 deletions spec/controllers/accounts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
:before,
:confirm_two_factor_authenticated,
)
expect(subject).to have_actions(
:before,
:confirm_user_is_not_suspended,
)
end
end

Expand Down Expand Up @@ -74,6 +78,22 @@
end
end

context 'when a user is suspended' do
render_views
it 'redirects to contact support page' do
user = create(
:user,
:fully_registered,
)

user.suspend!
sign_in user
get :show

expect(response).to redirect_to(user_please_call_url)
end
end

context 'when logging in with piv/cac' do
context 'when the user is proofed' do
it 'renders a locked profile' do
Expand Down
20 changes: 20 additions & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@ def index
end
end

describe '#confirm_user_is_not_suspended' do
controller do
before_action :confirm_user_is_not_suspended

def index
render plain: 'Hello'
end
end

context 'when user is suspended' do
it 'redirects to users please call page' do
user = create(:user, :suspended)
sign_in user
get :index

expect(response).to redirect_to user_please_call_url
end
end
end

describe '#confirm_two_factor_authenticated' do
controller do
before_action :confirm_two_factor_authenticated
Expand Down
21 changes: 21 additions & 0 deletions spec/controllers/users/please_call_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'rails_helper'

RSpec.describe Users::PleaseCallController do
let(:user) { create(:user, :suspended) }

before do
stub_sign_in(user)
end

it 'renders the show template' do
stub_analytics

expect(@analytics).to receive(:track_event).with(
'User Suspension: Please call visited',
)

get :show

expect(response).to render_template :show
end
end
29 changes: 29 additions & 0 deletions spec/views/users/please_call/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'rails_helper'

RSpec.describe 'users/please_call/show.html.erb' do
before do
render
end

it 'includes a message instructing them to call contact center' do
expect(rendered).to have_text(
strip_tags(
t(
'users.suspended_sign_in_account.contact_details',
contact_number: IdentityConfig.store.idv_contact_phone_number,
),
),
)
end

it 'display support code' do
expect(rendered).to have_text(
strip_tags(
t(
'users.suspended_sign_in_account.error_details',
error_code: 'EFGHI',
),
),
)
end
end