diff --git a/app/controllers/verify/address_controller.rb b/app/controllers/verify/address_controller.rb index 9af30925677..dbc9d6312f4 100644 --- a/app/controllers/verify/address_controller.rb +++ b/app/controllers/verify/address_controller.rb @@ -6,8 +6,33 @@ class AddressController < ApplicationController def index; end + def create + response = Idv::AddressDeliveryMethodForm.new.submit( + address_delivery_params.to_h.symbolize_keys + ) + + if response.success? + redirect_to address_delivery_destination + else + render :index + end + end + private + def address_delivery_params + params.permit(:address_delivery_method) + end + + def address_delivery_destination + destination = address_delivery_params[:address_delivery_method] + if destination == 'phone' + verify_phone_path + elsif destination == 'usps' + verify_usps_path + end + end + def confirm_step_needed redirect_to verify_review_url if idv_session.address_mechanism_chosen? end diff --git a/app/forms/idv/address_delivery_method_form.rb b/app/forms/idv/address_delivery_method_form.rb new file mode 100644 index 00000000000..dd5cea037a9 --- /dev/null +++ b/app/forms/idv/address_delivery_method_form.rb @@ -0,0 +1,17 @@ +module Idv + class AddressDeliveryMethodForm + attr_accessor :address_delivery_method + + def submit(address_delivery_method: '') + self.address_delivery_method = address_delivery_method + + FormResponse.new(success: valid_address_delivery_method?, errors: {}) + end + + private + + def valid_address_delivery_method? + %w[phone usps].include? address_delivery_method + end + end +end diff --git a/app/views/verify/address/index.html.slim b/app/views/verify/address/index.html.slim index 8044f6c6a4e..41be657be62 100644 --- a/app/views/verify/address/index.html.slim +++ b/app/views/verify/address/index.html.slim @@ -3,13 +3,25 @@ h1.h2 p = decorated_session.verification_method_choice -.clearfix - .sm-col.sm-col-12.md-col-6 - = link_to t('idv.buttons.activate_by_phone'), verify_phone_path, - class: 'btn btn-primary mb2 center inline-block' += form_tag + label.block.p2.border.rounded-md.border-light-blue.mb2 for="address_delivery_method_phone" + .radio + = radio_button_tag 'address_delivery_method', :phone, true + span.indicator + strong.blue.block = t('idv.messages.select_verification_form.phone_header') + span = t('idv.messages.select_verification_form.phone_message') + + // USPS verification should always be enabled in prod. + // This check is a convenience for lower envs. - if FeatureManagement.enable_usps_verification? - .sm-col.sm-col-12.md-col-6 - = link_to t('idv.buttons.activate_by_mail'), verify_usps_path, - class: 'btn btn-outline rounded-lg mb2 center' + label.block.p2.border.rounded-md.border-light-blue.mb2 for="address_delivery_method_usps" + .radio + = radio_button_tag 'address_delivery_method', :usps + span.indicator + strong.blue.block = t('idv.messages.select_verification_form.usps_header') + span = t('idv.messages.select_verification_form.usps_message') + + = button_tag t('forms.buttons.continue'), type: 'submit', + class: 'btn btn-primary col-6 mb2 p2 rounded-lg inline-block' = render 'shared/cancel', link: verify_cancel_path diff --git a/config/locales/idv/en.yml b/config/locales/idv/en.yml index f116258d9c4..39f9fd6efab 100644 --- a/config/locales/idv/en.yml +++ b/config/locales/idv/en.yml @@ -2,8 +2,6 @@ en: idv: buttons: - activate_by_mail: Activate by mail - activate_by_phone: Activate by phone cancel: Cancel and return to your profile continue: Continue identity verification continue_plain: Continue @@ -149,11 +147,17 @@ en: financial_info: Where is my financial account information? info_verified_html: We found records matching your %{phone_message} intro: Your verified information - select_verification_with_sp: To protect you from identity fraud, you can't use - your account at %{sp_name} until you activate it by entering a confirmation - code. - select_verification_without_sp: In order to protect your account from identity - fraud, your profile will not be activated until you enter a confirmation code. + select_verification_form: + phone_header: Get a code by phone + phone_message: The billing address for your phone must match the address you + gave us. + usps_header: Get a code by letter + usps_message: We'll mail a code to the address you gave us. It will take 5-10 + days to reach you. + select_verification_with_sp: To protect you from identity fraud, we will contact + you to confirm that this %{sp_name} account is legitimate. + select_verification_without_sp: To protect you from identity fraud, we will + contact you to confirm that this account is legitimate. sessions: no_pii: Do not use real personal information (demo purposes only) pii: personal information @@ -223,7 +227,7 @@ en: otp_delivery_method: Get a code by phone phone: Phone number of record review: Review and submit - select_verification: Activate your account + select_verification: Choose how to confirm your address session: phone: Get a code by telephone review: Encrypt your verified data by entering your password diff --git a/config/locales/idv/es.yml b/config/locales/idv/es.yml index 00ca11732f3..e690d1b675f 100644 --- a/config/locales/idv/es.yml +++ b/config/locales/idv/es.yml @@ -2,8 +2,6 @@ es: idv: buttons: - activate_by_mail: Acitive por email - activate_by_phone: Active por teléfono cancel: Cancele y regrese a su perfil continue: Continúe la verificación de identidad continue_plain: Continúe @@ -151,6 +149,11 @@ es: financial_info: "¿Dónde está la información de mi cuenta financiera?" info_verified_html: Encontramos registros que coinciden con su %{phone_message} intro: Su información verificada + select_verification_form: + phone_header: NOT TRANSLATED YET + phone_message: NOT TRANSLATED YET + usps_header: NOT TRANSLATED YET + usps_message: NOT TRANSLATED YET select_verification_with_sp: Para protegerlo de robo de identidad, no puede utilizar su cuenta en %{sp_name} hasta que la active ingresando un código de confirmación. @@ -197,9 +200,9 @@ es: sessions: fail: Su cuenta está bloqueada por 24 horas antes de que pueda intentar verificarla de nuevo. - jobfail: NOT TRANSLATED YET heading: No hemos podido encontrar registros que coincidan con su información personal. + jobfail: NOT TRANSLATED YET timeout: NOT TRANSLATED YET warning: Compruebe la información que ingresó. Los errores comunes son números incorrectos de Seguro Social, código postal o fecha de nacimiento. diff --git a/config/locales/idv/fr.yml b/config/locales/idv/fr.yml index 2969d465d18..13160a238ea 100644 --- a/config/locales/idv/fr.yml +++ b/config/locales/idv/fr.yml @@ -2,8 +2,6 @@ fr: idv: buttons: - activate_by_mail: Activer par la poste - activate_by_phone: Activer par téléphone cancel: Annuler et retourner à votre profil continue: Continuer la vérification d'identité continue_plain: Continuer @@ -160,6 +158,11 @@ fr: info_verified_html: Nous avons trouvé des données qui correspondent à votre %{phone_message} intro: Vos informations vérifiées + select_verification_form: + phone_header: NOT TRANSLATED YET + phone_message: NOT TRANSLATED YET + usps_header: NOT TRANSLATED YET + usps_message: NOT TRANSLATED YET select_verification_with_sp: Afin de vous protéger des fraudes d'identité, vous ne pouvez pas utiliser votre compte au %{sp_name} tant que vous ne l'aurez pas activé en entrant votre code de confirmation. diff --git a/config/routes.rb b/config/routes.rb index 44b8b4464c8..993bc784c36 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -132,6 +132,7 @@ get '/verify' => 'verify#index' get '/verify/activated' => 'verify#activated' get '/verify/address' => 'verify/address#index' + post '/verify/address' => 'verify/address#create' get '/verify/cancel' => 'verify#cancel' get '/verify/come_back_later' => 'verify/come_back_later#show' get '/verify/confirmations' => 'verify/confirmations#show' diff --git a/logstash.conf.example b/logstash.conf.example index 6569f8d2a98..e69de29bb2d 100644 --- a/logstash.conf.example +++ b/logstash.conf.example @@ -1,9 +0,0 @@ -input { - file { - path => "path_to_repo/log/events.log" - } -} -output { - elasticsearch { hosts => ["localhost:9200"] } - stdout { codec => rubydebug } -} diff --git a/spec/forms/idv/address_delivery_method_form_spec.rb b/spec/forms/idv/address_delivery_method_form_spec.rb new file mode 100644 index 00000000000..1ebd38d8813 --- /dev/null +++ b/spec/forms/idv/address_delivery_method_form_spec.rb @@ -0,0 +1,43 @@ +require 'rails_helper' + +describe Idv::AddressDeliveryMethodForm do + subject { Idv::AddressDeliveryMethodForm.new } + + describe '#submit' do + context 'when delivery method is phone' do + it 'submits without error' do + response = subject.submit(address_delivery_method: 'phone') + + expect(response).to be_a(FormResponse) + expect(response.success?).to eq(true) + end + end + + context 'when delivery method is usps' do + it 'submits without error' do + response = subject.submit(address_delivery_method: 'usps') + + expect(response).to be_a(FormResponse) + expect(response.success?).to eq(true) + end + end + + context 'when delivery method is invalid' do + it 'submits with error' do + response = subject.submit(address_delivery_method: 'nonsense') + + expect(response).to be_a(FormResponse) + expect(response.success?).to eq(false) + end + end + + context 'when delivery method is blank' do + it 'submits with error' do + response = subject.submit(address_delivery_method: '') + + expect(response).to be_a(FormResponse) + expect(response.success?).to eq(false) + end + end + end +end diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index 0332cb15efd..0f753b35238 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -33,7 +33,7 @@ def fill_out_idv_previous_address_ok fill_in 'profile_prev_address1', with: '456 Other Ave' fill_in 'profile_prev_city', with: 'Elsewhere' select 'Missouri', from: 'profile_prev_state' - fill_in 'profile_prev_zipcode', with: '12345' + fill_in 'profile_prev_zipcode', with: '64000' end def fill_out_idv_previous_address_fail @@ -68,11 +68,19 @@ def click_idv_continue end def click_idv_address_choose_phone - click_link t('idv.buttons.activate_by_phone') + # we're capturing the click on the label element via the unique "for" attribute + # which matches against the radio button's ID, + # so that we can capture any click within the label. + find("label[for='address_delivery_method_phone']").click + click_on t('forms.buttons.continue') end def click_idv_address_choose_usps - click_link t('idv.buttons.activate_by_mail') + # we're capturing the click on the label element via the unique "for" attribute + # which matches against the radio button's ID, + # so that we can capture any click within the label. + find("label[for='address_delivery_method_usps']").click + click_on t('forms.buttons.continue') end def choose_idv_otp_delivery_method_sms diff --git a/spec/support/idv_examples/max_attempts.rb b/spec/support/idv_examples/max_attempts.rb index f7cd417c184..600c68ce506 100644 --- a/spec/support/idv_examples/max_attempts.rb +++ b/spec/support/idv_examples/max_attempts.rb @@ -53,7 +53,7 @@ expect(current_path).to eq verify_session_result_path end - scenario 'fincance shows failure flash message after max attempts', :email do + scenario 'finance shows failure flash message after max attempts', :email do visit_idp_from_sp_with_loa3(sp) register_user diff --git a/spec/support/idv_examples/usps_verification_selection.rb b/spec/support/idv_examples/usps_verification_selection.rb index 00723d74b9d..a8d0cd2047c 100644 --- a/spec/support/idv_examples/usps_verification_selection.rb +++ b/spec/support/idv_examples/usps_verification_selection.rb @@ -11,7 +11,6 @@ click_idv_continue click_idv_address_choose_usps - click_on t('idv.buttons.mail.send') expect(current_path).to eq verify_review_path