Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dad14d9
Improve Configuration Setting Validation
rlxdev Jul 18, 2017
a86a124
Fix verification by mail redirect logic (#1569)
gemfarmer Jul 24, 2017
a40b46c
Fix load testing script for new phone form
zachmargolis Jul 27, 2017
6573ad2
Merge pull request #1572 from 18F/margolis-update-load-test-scripts
zachmargolis Jul 27, 2017
50bfd66
Add OTP delivery prefence to update phone form
jmhooper Jul 27, 2017
29b4210
Merge pull request #1571 from 18F/jmhooper-update-user-phone-otp-sele…
jmhooper Jul 27, 2017
183efc8
Update loading spinner
zachmargolis Jul 27, 2017
9a29d6c
Merge pull request #1573 from 18F/margolis-updated-spinner
zachmargolis Jul 27, 2017
1ccd05d
Merge pull request #1569 from 18F/bsh-usps-verification
monfresh Jul 28, 2017
80a0598
Merge pull request #1558 from rlxdev/rlxdev-cfg_validator
monfresh Jul 28, 2017
4e89290
Update digital analytics program i18n
zachmargolis Jul 28, 2017
fef5ba5
Merge pull request #1575 from 18F/margolis-update-dap-comment
zachmargolis Jul 28, 2017
3fe2510
Allow pre-filling OTP in dev environment
zachmargolis Jul 31, 2017
5284188
Merge pull request #1577 from 18F/margolis-load-test-in-dev
zachmargolis Jul 31, 2017
b49503f
Use shared examples for OIDC and SAML LOA3 specs
monfresh Jul 31, 2017
2f82292
Merge pull request #1579 from 18F/mb-refactor-sp-specs
monfresh Aug 1, 2017
f2845b7
Reorder phone confirmation and review page
jmhooper Aug 1, 2017
a9526ea
Merge pull request #1530 from 18F/jmhooper-verify-phone-password-flow
jmhooper Aug 1, 2017
d918437
Add CBP OARS prod config
blacktm Aug 1, 2017
0728a00
Move USPS verification specs to shared example
monfresh Aug 1, 2017
2258bd7
Merge pull request #1581 from 18F/mb-fix-oidc-controller
monfresh Aug 2, 2017
001586e
Move USPS verification selection to shared example
jmhooper Aug 1, 2017
f3644a4
Merge pull request #1583 from 18F/jmhooper-usps-verification-shared-e…
jmhooper Aug 2, 2017
c7ffef0
Merge pull request #1580 from 18F/add-cbp-oars-prod
monfresh Aug 2, 2017
30999cd
Use style-guide to import fonts and favicons
hursey013 Aug 1, 2017
574c5ac
Merge pull request #1582 from 18F/bh-use-style-guide
hursey013 Aug 3, 2017
c1c8da1
Add come back later page
jmhooper Aug 1, 2017
297d2f5
Merge pull request #1584 from 18F/jmhooper-come-back-later-page
jmhooper Aug 3, 2017
daf4e4c
Use a whitelist approach for URL parameters
monfresh Aug 4, 2017
e66b04d
Merge pull request #1587 from 18F/mb-whitelist-params
monfresh Aug 4, 2017
913cbe4
Update CBP OARS SP config
blacktm Aug 4, 2017
537584e
Merge pull request #1588 from 18F/update-cbs-oars-sp
blacktm Aug 4, 2017
6bce21d
Revert "Merge pull request #1582 from 18F/bh-use-style-guide"
hursey013 Aug 4, 2017
5094016
Merge pull request #1589 from 18F/bh-undo-style-guide-npm
hursey013 Aug 4, 2017
aeca825
Format phone number of record as a US number
jmhooper Jul 31, 2017
81cad98
Log useful error message when failing to load key.
brodygov Aug 3, 2017
10eb0cc
Merge pull request #1578 from 18F/jmhooper-idv-flow-phone-formatter
jmhooper Aug 7, 2017
7ca0230
Merge pull request #1585 from 18F/brody/key-load-err-msg
jmhooper Aug 7, 2017
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/assets/images/come-back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/images/spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/spinner@2x.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/assets/javascripts/app/form-field-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import DateFormatter from './modules/date-formatter';
import InternationalPhoneFormatter from './modules/international-phone-formatter';
import NumericFormatter from './modules/numeric-formatter';
import PersonalKeyFormatter from './modules/personal-key-formatter';
import USPhoneFormatter from './modules/us-phone-formatter';
import ZipCodeFormatter from './modules/zip-code-formatter';


Expand All @@ -15,6 +16,7 @@ function formatForm() {
['.mfa', new NumericFormatter()],
['.mortgage', new NumericFormatter()],
['.phone', new InternationalPhoneFormatter()],
['.us-phone', new USPhoneFormatter()],
['.personal-key', new PersonalKeyFormatter()],
['.ssn', new SocialSecurityNumberFormatter()],
['.zipcode', new ZipCodeFormatter()],
Expand Down
16 changes: 16 additions & 0 deletions app/assets/javascripts/app/modules/us-phone-formatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { PhoneFormatter } from 'field-kit';

class USPhoneFormatter extends PhoneFormatter {
isChangeValid(change, error) {
const match = change.proposed.text.match(/^\+(\d?)/);
if (match && match[1] === '') {
change.proposed.text = '+1';
change.proposed.selectedRange.start = 4;
} else if (match && match[1] !== '1') {
return false;
}
return super.isChangeValid(change, error);
}
}

export default USPhoneFormatter;
6 changes: 3 additions & 3 deletions app/assets/javascripts/app/phone-internationalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const I18n = window.LoginGov.I18n;
const phoneFormatter = new PhoneFormatter();

const getPhoneUnsupportedAreaCodeCountry = (areaCode) => {
const form = document.querySelector('#new_two_factor_setup_form');
const form = document.querySelector('[data-international-phone-form]');
const phoneUnsupportedAreaCodes = JSON.parse(form.dataset.unsupportedAreaCodes);
return phoneUnsupportedAreaCodes[areaCode];
};
Expand Down Expand Up @@ -52,8 +52,8 @@ const unsupportedPhoneOTPDeliveryWarningMessage = (phone) => {
};

const updateOTPDeliveryMethods = () => {
const phoneRadio = document.querySelector('#two_factor_setup_form_otp_delivery_preference_voice');
const smsRadio = document.querySelector('#two_factor_setup_form_otp_delivery_preference_sms');
const phoneRadio = document.querySelector('[data-international-phone-form] .otp_delivery_preference_voice');
const smsRadio = document.querySelector('[data-international-phone-form] .otp_delivery_preference_sms');

if (!phoneRadio || !smsRadio) {
return;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/components/_loading.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.loading-spinner {
margin: auto;
width: 100px;
width: 144px;
}
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def redirect_on_timeout
return unless params[:timeout]

flash[:notice] = t('notices.session_cleared', minutes: Figaro.env.session_timeout_in_minutes)
redirect_to url_for(params.except(:timeout))
redirect_to url_for(permitted_timeout_params)
end

def permitted_timeout_params
params.permit(:request_id)
end

def current_sp
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/concerns/two_factor_authenticatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def reset_otp_session_data

def after_otp_verification_confirmation_path
if idv_context?
verify_confirmations_path
verify_review_path
elsif after_otp_action_required?
after_otp_action_path
else
Expand Down Expand Up @@ -231,9 +231,11 @@ def unconfirmed_phone?
user_session[:unconfirmed_phone] && idv_or_confirmation_context?
end

# rubocop:disable MethodLength
def phone_view_data
{
confirmation_for_phone_change: confirmation_for_phone_change?,
confirmation_for_idv: idv_context?,
phone_number: display_phone_to_deliver_to,
code_value: direct_otp_code,
otp_delivery_preference: two_factor_authentication_method,
Expand All @@ -243,6 +245,7 @@ def phone_view_data
totp_enabled: current_user.totp_enabled?,
}.merge(generic_data)
end
# rubocop:enable MethodLength

def authenticator_view_data
{
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/users/phones_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class PhonesController < ReauthnRequiredController
before_action :confirm_two_factor_authenticated

def edit
@update_user_phone_form = UpdateUserPhoneForm.new(current_user)
@user_phone_form = UserPhoneForm.new(current_user)
end

def update
@update_user_phone_form = UpdateUserPhoneForm.new(current_user)
@user_phone_form = UserPhoneForm.new(current_user)

if @update_user_phone_form.submit(user_params).success?
if @user_phone_form.submit(user_params).success?
process_updates
bypass_sign_in current_user
else
Expand All @@ -22,14 +22,14 @@ def update
private

def user_params
params.require(:update_user_phone_form).permit(:phone, :international_code)
params.require(:user_phone_form).permit(:phone, :international_code, :otp_delivery_preference)
end

def process_updates
if @update_user_phone_form.phone_changed?
if @user_phone_form.phone_changed?
analytics.track_event(Analytics::PHONE_CHANGE_REQUESTED)
flash[:notice] = t('devise.registrations.phone_update_needs_confirmation')
prompt_to_confirm_phone(phone: @update_user_phone_form.phone)
prompt_to_confirm_phone(phone: @user_phone_form.phone)
else
redirect_to account_url
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ class TwoFactorAuthenticationSetupController < ApplicationController
skip_before_action :handle_two_factor_authentication

def index
@two_factor_setup_form = TwoFactorSetupForm.new(current_user)
@unsupported_area_codes = PhoneNumberCapabilities::VOICE_UNSUPPORTED_US_AREA_CODES
@user_phone_form = UserPhoneForm.new(current_user)
analytics.track_event(Analytics::USER_REGISTRATION_PHONE_SETUP_VISIT)
end

def set
@two_factor_setup_form = TwoFactorSetupForm.new(current_user)
result = @two_factor_setup_form.submit(params[:two_factor_setup_form])
@user_phone_form = UserPhoneForm.new(current_user)
result = @user_phone_form.submit(params[:user_phone_form])

analytics.track_event(Analytics::MULTI_FACTOR_AUTH_PHONE_SETUP, result.to_h)

Expand All @@ -37,7 +36,7 @@ def authorize_otp_setup
end

def process_valid_form
prompt_to_confirm_phone(phone: @two_factor_setup_form.phone)
prompt_to_confirm_phone(phone: @user_phone_form.phone)
end
end
end
20 changes: 20 additions & 0 deletions app/controllers/verify/come_back_later_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Verify
class ComeBackLaterController < ApplicationController
include IdvSession

before_action :confirm_idv_session_completed
before_action :confirm_usps_verification_method_chosen

def show; end

private

def confirm_idv_session_completed
redirect_to account_path if idv_session.profile.blank?
end

def confirm_usps_verification_method_chosen
redirect_to account_path unless idv_session.address_verification_mechanism == 'usps'
end
end
end
2 changes: 2 additions & 0 deletions app/controllers/verify/confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def update
def next_step
if session[:sp] && !pending_profile?
sign_up_completed_url
elsif pending_profile? && idv_session.address_verification_mechanism == 'usps'
verify_come_back_later_path
else
after_sign_in_path_for(current_user)
end
Expand Down
23 changes: 21 additions & 2 deletions app/controllers/verify/phone_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Verify
class PhoneController < ApplicationController
include IdvStepConcern
include IdvFailureConcern
include PhoneConfirmation

before_action :confirm_step_needed
before_action :confirm_step_allowed
Expand Down Expand Up @@ -31,7 +32,7 @@ def show
increment_step_attempts

if result.success?
redirect_to verify_review_url
redirect_to_next_step
else
render_failure
render :new
Expand All @@ -40,6 +41,24 @@ def show

private

def redirect_to_next_step
if phone_confirmation_required?
prompt_to_confirm_phone(phone: idv_session.params[:phone], context: 'idv')
else
redirect_to verify_review_url
end
end

def phone_confirmation_required?
normalized_phone = idv_session.params[:phone]
return false if normalized_phone.blank?

formatted_phone = normalized_phone.phony_formatted(
format: :international, normalize: :US, spaces: ' '
)
formatted_phone != current_user.phone
end

def submit_idv_job
SubmitIdvJob.new(
vendor_validator_class: Idv::PhoneValidator,
Expand Down Expand Up @@ -69,7 +88,7 @@ def step_params
end

def confirm_step_needed
redirect_to verify_review_path if idv_session.vendor_phone_confirmation == true
redirect_to_next_step if idv_session.vendor_phone_confirmation == true
end

def idv_form
Expand Down
30 changes: 12 additions & 18 deletions app/controllers/verify/review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ReviewController < ApplicationController
include PhoneConfirmation

before_action :confirm_idv_steps_complete
before_action :confirm_idv_phone_confirmed
before_action :confirm_current_password, only: [:create]

def confirm_idv_steps_complete
Expand All @@ -12,6 +13,16 @@ def confirm_idv_steps_complete
return redirect_to(verify_address_path) unless idv_address_complete?
end

def confirm_idv_phone_confirmed
return unless idv_session.address_verification_mechanism == 'phone'
return if idv_session.phone_confirmed?

prompt_to_confirm_phone(
phone: idv_session.params[:phone],
context: 'idv'
)
end

def confirm_current_password
return if valid_password?

Expand All @@ -34,7 +45,7 @@ def new

def create
init_profile
redirect_to_next_step
redirect_to verify_confirmations_path
analytics.track_event(Analytics::IDV_REVIEW_COMPLETE)
end

Expand Down Expand Up @@ -68,27 +79,10 @@ def init_profile
idv_session.cache_encrypted_pii(current_user.user_access_key)
end

def redirect_to_next_step
if phone_confirmation_required?
prompt_to_confirm_phone(phone: idv_params[:phone], context: 'idv')
else
redirect_to verify_confirmations_path
end
end

def idv_params
idv_session.params
end

def phone_confirmation_required?
normalized_phone = idv_params[:phone]
return false if normalized_phone.blank?

formatted_phone = PhoneFormatter.new.format(normalized_phone)
formatted_phone != current_user.phone &&
idv_session.address_verification_mechanism == 'phone'
end

def valid_password?
current_user.valid_password?(password)
end
Expand Down
Loading