diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index aee94d56303..2bacacdd847 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -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' diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2be9690400b..2a68ed826a0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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? @@ -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) diff --git a/app/controllers/users/please_call_controller.rb b/app/controllers/users/please_call_controller.rb new file mode 100644 index 00000000000..d0826ce9b03 --- /dev/null +++ b/app/controllers/users/please_call_controller.rb @@ -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 diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index fc73d164e6f..fd22ac3bbee 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -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 diff --git a/app/views/users/please_call/show.html.erb b/app/views/users/please_call/show.html.erb new file mode 100644 index 00000000000..10472bc7cfe --- /dev/null +++ b/app/views/users/please_call/show.html.erb @@ -0,0 +1,11 @@ +<%= render( + 'idv/shared/error', + heading: t('users.suspended_sign_in_account.heading'), + ) do %> +

+ <%= t('users.suspended_sign_in_account.contact_details', contact_number: IdentityConfig.store.idv_contact_phone_number) %> +

+

+ <%= t('users.suspended_sign_in_account.error_details', error_code: IdentityConfig.store.account_suspended_support_code) %> +

+<% end %> diff --git a/config/locales/users/en.yml b/config/locales/users/en.yml index f38607495a0..5e54cdf9c2d 100644 --- a/config/locales/users/en.yml +++ b/config/locales/users/en.yml @@ -36,3 +36,8 @@ en: 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 diff --git a/config/locales/users/es.yml b/config/locales/users/es.yml index 5e3ff4c2087..ff569db7d83 100644 --- a/config/locales/users/es.yml +++ b/config/locales/users/es.yml @@ -37,3 +37,8 @@ es: 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 diff --git a/config/locales/users/fr.yml b/config/locales/users/fr.yml index d92c09ca937..a4dcbd3cc0d 100644 --- a/config/locales/users/fr.yml +++ b/config/locales/users/fr.yml @@ -39,3 +39,8 @@ fr: 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 diff --git a/config/routes.rb b/config/routes.rb index f85d4a57bbd..57a66e9e30f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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') diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index 96afc76be3c..5f881a0834b 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -7,6 +7,10 @@ :before, :confirm_two_factor_authenticated, ) + expect(subject).to have_actions( + :before, + :confirm_user_is_not_suspended, + ) end end @@ -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 diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index b7104b005d1..52840fd4e7c 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -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 diff --git a/spec/controllers/users/please_call_controller_spec.rb b/spec/controllers/users/please_call_controller_spec.rb new file mode 100644 index 00000000000..cc78b0f7449 --- /dev/null +++ b/spec/controllers/users/please_call_controller_spec.rb @@ -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 diff --git a/spec/views/users/please_call/show.html.erb_spec.rb b/spec/views/users/please_call/show.html.erb_spec.rb new file mode 100644 index 00000000000..72894bbb85f --- /dev/null +++ b/spec/views/users/please_call/show.html.erb_spec.rb @@ -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