From ab8dce2f76ba94374336ff1ca3aa2aa0f28e0c03 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Tue, 11 Sep 2018 20:40:20 -0500 Subject: [PATCH 1/5] LG-627 Don't automatically select SMS during IdV **Why**: When a user uses a different number for address verification than the one they used for 2FA they are asked to choose if they'd like to get the code sent to them via text message or voice message. Text message is auto-selected but it should default to no selection so users don't think text message is the only option or that it's automatically compatible with their phone. --- .../idv/otp_delivery_method_controller.rb | 9 +++++++-- app/views/idv/otp_delivery_method/new.html.slim | 3 ++- config/locales/idv/en.yml | 1 + config/locales/idv/es.yml | 1 + config/locales/idv/fr.yml | 1 + .../phone_otp_delivery_selection_step_spec.rb | 14 ++++++++++++++ spec/support/features/idv_helper.rb | 8 +++++--- 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/controllers/idv/otp_delivery_method_controller.rb b/app/controllers/idv/otp_delivery_method_controller.rb index 2fd67c5f60e..ace9dd6d13d 100644 --- a/app/controllers/idv/otp_delivery_method_controller.rb +++ b/app/controllers/idv/otp_delivery_method_controller.rb @@ -16,7 +16,7 @@ def new def create result = otp_delivery_selection_form.submit(otp_delivery_selection_params) analytics.track_event(Analytics::IDV_PHONE_OTP_DELIVERY_SELECTION_SUBMITTED, result.to_h) - return render(:new) unless result.success? + return render_new_with_error_message unless result.success? send_phone_confirmation_otp_and_handle_result rescue Twilio::REST::RestError, PhoneVerification::VerifyError => exception invalid_phone_number(exception) @@ -38,11 +38,16 @@ def set_idv_phone end def otp_delivery_selection_params - params.require(:otp_delivery_selection_form).permit( + params.permit(:otp_delivery_selection_form).permit( :otp_delivery_preference ) end + def render_new_with_error_message + flash[:error] = t('idv.errors.unsupported_otp_delivery_method') + render :new + end + def send_phone_confirmation_otp_and_handle_result save_delivery_preference_in_session result = send_phone_confirmation_otp diff --git a/app/views/idv/otp_delivery_method/new.html.slim b/app/views/idv/otp_delivery_method/new.html.slim index 92eac66e68c..8000850574e 100644 --- a/app/views/idv/otp_delivery_method/new.html.slim +++ b/app/views/idv/otp_delivery_method/new.html.slim @@ -6,7 +6,8 @@ p.mt1 = t('idv.messages.otp_delivery_method.phone_number_html', fieldset.mb3.p0.border-none label.btn-border.col-12.mb1 .radio - = radio_button_tag 'otp_delivery_selection_form[otp_delivery_preference]', :sms, true, + = radio_button_tag 'otp_delivery_selection_form[otp_delivery_preference]', + :sms, false, class: :otp_delivery_preference_sms span.indicator.mt-tiny span.blue.bold.fs-20p diff --git a/config/locales/idv/en.yml b/config/locales/idv/en.yml index 8173dd55360..de033b638ba 100644 --- a/config/locales/idv/en.yml +++ b/config/locales/idv/en.yml @@ -32,6 +32,7 @@ en: zipcode: 'Your zipcode must be entered in as #####-####' unsupported_jurisdiction: Sorry, we can't verify people from this state. unsupported_jurisdiction_sp: Please visit %{sp_name} to access your account. + unsupported_otp_delivery_method: Please select a valid delivery method. failure: attempts: one: You have 1 attempt remaining. diff --git a/config/locales/idv/es.yml b/config/locales/idv/es.yml index abbff0b119d..0bde17a87ee 100644 --- a/config/locales/idv/es.yml +++ b/config/locales/idv/es.yml @@ -32,6 +32,7 @@ es: unsupported_jurisdiction: Lo sentimos, no podemos verificar personas de este estado. unsupported_jurisdiction_sp: Visita %{sp_name} para acceder a tu cuenta. + unsupported_otp_delivery_method: NOT TRANSLATED YET failure: attempts: one: Tiene usted 1 intento restante. diff --git a/config/locales/idv/fr.yml b/config/locales/idv/fr.yml index 4941a8f023c..c8712d2ad2b 100644 --- a/config/locales/idv/fr.yml +++ b/config/locales/idv/fr.yml @@ -36,6 +36,7 @@ fr: de cet état. unsupported_jurisdiction_sp: Veuillez visiter %{sp_name} pour accéder à votre compte. + unsupported_otp_delivery_method: NOT TRANSLATED YET failure: attempts: one: Il ne vous reste qu' strongune tentative./strong diff --git a/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb b/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb index 41eb1c7b9d7..4ebf2e19e64 100644 --- a/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb +++ b/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb @@ -31,6 +31,20 @@ end end + context 'the user does not make a selection' do + it 'does not send a voice call or sms and renders an error' do + expect(VoiceOtpSenderJob).to_not receive(:perform_later) + expect(SmsOtpSenderJob).to_not receive(:perform_later) + + start_idv_from_sp + complete_idv_steps_before_phone_otp_delivery_selection_step + click_on t('idv.buttons.send_confirmation_code') + + expect(page).to have_content(t('idv.errors.unsupported_otp_delivery_method')) + expect(current_path).to eq(idv_otp_delivery_method_url) + end + end + context 'with a non-US number' do let(:bahamas_phone) { '+12423270143' } diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index 33980872edb..25d2034a366 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -65,9 +65,11 @@ def click_idv_continue end def choose_idv_otp_delivery_method_sms - using_wait_time(5) do - click_on t('idv.buttons.send_confirmation_code') - end + page.find( + 'label', + text: t('devise.two_factor_authentication.otp_delivery_preference.sms') + ).click + click_on t('idv.buttons.send_confirmation_code') end def choose_idv_otp_delivery_method_voice From 18725c2fb40bec7bdfe8a909179c4ae45bfd7488 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Tue, 11 Sep 2018 21:27:43 -0500 Subject: [PATCH 2/5] fix form params issue --- .../idv/otp_delivery_method_controller.rb | 4 +--- .../idv/otp_delivery_method/new.html.slim | 4 ++-- .../otp_delivery_method_controller_spec.rb | 24 +++---------------- .../phone_otp_delivery_selection_step_spec.rb | 2 +- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/app/controllers/idv/otp_delivery_method_controller.rb b/app/controllers/idv/otp_delivery_method_controller.rb index ace9dd6d13d..b9f2812f2b6 100644 --- a/app/controllers/idv/otp_delivery_method_controller.rb +++ b/app/controllers/idv/otp_delivery_method_controller.rb @@ -38,9 +38,7 @@ def set_idv_phone end def otp_delivery_selection_params - params.permit(:otp_delivery_selection_form).permit( - :otp_delivery_preference - ) + params.permit(:otp_delivery_preference) end def render_new_with_error_message diff --git a/app/views/idv/otp_delivery_method/new.html.slim b/app/views/idv/otp_delivery_method/new.html.slim index 8000850574e..f5d08e62bec 100644 --- a/app/views/idv/otp_delivery_method/new.html.slim +++ b/app/views/idv/otp_delivery_method/new.html.slim @@ -6,7 +6,7 @@ p.mt1 = t('idv.messages.otp_delivery_method.phone_number_html', fieldset.mb3.p0.border-none label.btn-border.col-12.mb1 .radio - = radio_button_tag 'otp_delivery_selection_form[otp_delivery_preference]', + = radio_button_tag 'otp_delivery_preference', :sms, false, class: :otp_delivery_preference_sms span.indicator.mt-tiny @@ -16,7 +16,7 @@ p.mt1 = t('idv.messages.otp_delivery_method.phone_number_html', = t('devise.two_factor_authentication.two_factor_choice_options.sms_info') label.btn-border.col-12.mb0 .radio - = radio_button_tag 'otp_delivery_selection_form[otp_delivery_preference]', + = radio_button_tag 'otp_delivery_preference', :voice, false, class: :otp_delivery_preference_voice span.indicator.mt-tiny diff --git a/spec/controllers/idv/otp_delivery_method_controller_spec.rb b/spec/controllers/idv/otp_delivery_method_controller_spec.rb index edf9430f78b..0e5fe4f6756 100644 --- a/spec/controllers/idv/otp_delivery_method_controller_spec.rb +++ b/spec/controllers/idv/otp_delivery_method_controller_spec.rb @@ -64,13 +64,7 @@ end describe '#create' do - let(:params) do - { - otp_delivery_selection_form: { - otp_delivery_preference: :sms, - }, - } - end + let(:params) { { otp_delivery_preference: :sms } } context 'user has not selected phone verification method' do before do @@ -130,13 +124,7 @@ end context 'user has selected voice' do - let(:params) do - { - otp_delivery_selection_form: { - otp_delivery_preference: :voice, - }, - } - end + let(:params) { { otp_delivery_preference: :voice } } it 'redirects to the otp send path for voice' do post :create, params: params @@ -162,13 +150,7 @@ end context 'form is invalid' do - let(:params) do - { - otp_delivery_selection_form: { - otp_delivery_preference: :🎷, - }, - } - end + let(:params) { { otp_delivery_preference: :🎷 } } it 'renders the new template' do post :create, params: params diff --git a/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb b/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb index 4ebf2e19e64..60a7656a5b7 100644 --- a/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb +++ b/spec/features/idv/steps/phone_otp_delivery_selection_step_spec.rb @@ -41,7 +41,7 @@ click_on t('idv.buttons.send_confirmation_code') expect(page).to have_content(t('idv.errors.unsupported_otp_delivery_method')) - expect(current_path).to eq(idv_otp_delivery_method_url) + expect(current_path).to eq(idv_otp_delivery_method_path) end end From e59a4cf58439aaf4c837a3cebeafc01fb633c3f3 Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Mon, 17 Sep 2018 13:45:29 -0500 Subject: [PATCH 3/5] Update english and spanish translations --- config/locales/idv/en.yml | 2 +- config/locales/idv/es.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/idv/en.yml b/config/locales/idv/en.yml index 786dbe05891..39af4f078b0 100644 --- a/config/locales/idv/en.yml +++ b/config/locales/idv/en.yml @@ -31,7 +31,7 @@ en: zipcode: 'Your zipcode must be entered in as #####-####' unsupported_jurisdiction: Sorry, we can't verify people from this state. unsupported_jurisdiction_sp: Please visit %{sp_name} to access your account. - unsupported_otp_delivery_method: Please select a valid delivery method. + unsupported_otp_delivery_method: Select a method to receive a code. failure: attempts: one: You have 1 attempt remaining. diff --git a/config/locales/idv/es.yml b/config/locales/idv/es.yml index 4e5c61fb843..0685ac044cc 100644 --- a/config/locales/idv/es.yml +++ b/config/locales/idv/es.yml @@ -31,7 +31,7 @@ es: unsupported_jurisdiction: Lo sentimos, no podemos verificar personas de este estado. unsupported_jurisdiction_sp: Visita %{sp_name} para acceder a tu cuenta. - unsupported_otp_delivery_method: NOT TRANSLATED YET + unsupported_otp_delivery_method: Seleccione una manera de recibir un código. failure: attempts: one: Tiene usted 1 intento restante. From 569832c4859da442a4b0e7c288432720a58b042d Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Mon, 17 Sep 2018 14:12:02 -0500 Subject: [PATCH 4/5] Fix translation in idv helper --- spec/support/features/idv_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index b6eac87e455..0b77bd47e95 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -67,7 +67,7 @@ def click_idv_continue def choose_idv_otp_delivery_method_sms page.find( 'label', - text: t('devise.two_factor_authentication.otp_delivery_preference.sms') + text: t('two_factor_authentication.otp_delivery_preference.sms') ).click click_on t('idv.buttons.send_confirmation_code') end From 92be586bdee1f06a81858c75a36e52bf7f9d881c Mon Sep 17 00:00:00 2001 From: Jonathan Hooper Date: Mon, 17 Sep 2018 15:25:16 -0500 Subject: [PATCH 5/5] Add french translation --- config/locales/idv/fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/idv/fr.yml b/config/locales/idv/fr.yml index 920b1d14ca5..a5c6988f21c 100644 --- a/config/locales/idv/fr.yml +++ b/config/locales/idv/fr.yml @@ -35,7 +35,7 @@ fr: de cet état. unsupported_jurisdiction_sp: Veuillez visiter %{sp_name} pour accéder à votre compte. - unsupported_otp_delivery_method: NOT TRANSLATED YET + unsupported_otp_delivery_method: Sélectionnez une méthode pour recevoir un code failure: attempts: one: Il ne vous reste qu' strongune tentative./strong