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 .reek
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ TooManyMethods:
- OpenidConnect::AuthorizationController
- Idv::Session
- User
- Verify::SessionsController
UncommunicativeMethodName:
exclude:
- PhoneConfirmationFlow
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/concerns/idv_failure_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ def render_failure
if step_attempts_exceeded?
@view_model = view_model(error: 'fail')
flash_message(type: :error)
elsif step.form_valid_but_vendor_validation_failed?
elsif form_valid_but_vendor_validation_failed?
@view_model = view_model(error: 'warning')
flash_message(type: :warning)
else
@view_model = view_model
end
end

def form_valid_but_vendor_validation_failed?
idv_form.valid? && !step.vendor_validation_passed?
end

def flash_message(type:)
flash.now[type.to_sym] = @view_model.flash_message
end
Expand Down
28 changes: 22 additions & 6 deletions app/controllers/verify/finance_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class FinanceController < ApplicationController

before_action :confirm_step_needed
before_action :confirm_step_allowed
before_action :submit_idv_form, only: [:create]

def new
@view_model = view_model
Expand All @@ -13,7 +14,7 @@ def new

def create
result = step.submit
analytics.track_event(Analytics::IDV_FINANCE_CONFIRMATION, result.to_h)
analytics.track_event(Analytics::IDV_FINANCE_CONFIRMATION_VENDOR, result.to_h)
increment_step_attempts

if result.success?
Expand All @@ -26,6 +27,16 @@ def create

private

def submit_idv_form
result = idv_form.submit(step_params)
analytics.track_event(Analytics::IDV_FINANCE_CONFIRMATION_FORM, result.to_h)

return if result.success?

@view_model = view_model
render_form
end

def step_name
:financials
end
Expand All @@ -38,12 +49,12 @@ def view_model(error: nil)
Verify::FinancialsNew.new(
error: error,
remaining_attempts: remaining_step_attempts,
idv_form: idv_finance_form
idv_form: idv_form
)
end

def idv_finance_form
@_idv_finance_form ||= Idv::FinanceForm.new(idv_session.params)
def idv_form
@_idv_form ||= Idv::FinanceForm.new(idv_session.params)
end

def handle_success
Expand All @@ -53,9 +64,9 @@ def handle_success

def step
@_step ||= Idv::FinancialsStep.new(
idv_form: idv_finance_form,
idv_form_params: idv_form.idv_params,
idv_session: idv_session,
params: step_params
vendor_params: vendor_params
)
end

Expand All @@ -70,5 +81,10 @@ def render_form
render 'verify/finance_other/new'
end
end

def vendor_params
finance_type = idv_form.finance_type
{ finance_type => idv_form.idv_params[finance_type] }
end
end
end
23 changes: 17 additions & 6 deletions app/controllers/verify/phone_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class PhoneController < ApplicationController

before_action :confirm_step_needed
before_action :confirm_step_allowed
before_action :submit_idv_form, only: [:create]

def new
@view_model = view_model
Expand All @@ -13,7 +14,7 @@ def new

def create
result = step.submit
analytics.track_event(Analytics::IDV_PHONE_CONFIRMATION, result.to_h)
analytics.track_event(Analytics::IDV_PHONE_CONFIRMATION_VENDOR, result.to_h)
increment_step_attempts

if result.success?
Expand All @@ -26,23 +27,33 @@ def create

private

def submit_idv_form
result = idv_form.submit(step_params)
analytics.track_event(Analytics::IDV_PHONE_CONFIRMATION_FORM, result.to_h)

return if result.success?

@view_model = view_model
render :new
end

def step_name
:phone
end

def step
@_step ||= Idv::PhoneStep.new(
idv_form: idv_phone_form,
idv_session: idv_session,
params: step_params
idv_form_params: idv_form.idv_params,
vendor_params: idv_form.phone
)
end

def view_model(error: nil)
Verify::PhoneNew.new(
error: error,
remaining_attempts: remaining_step_attempts,
idv_form: idv_phone_form
idv_form: idv_form
)
end

Expand All @@ -54,8 +65,8 @@ def confirm_step_needed
redirect_to verify_review_path if idv_session.phone_confirmation == true
end

def idv_phone_form
@_idv_phone_form ||= Idv::PhoneForm.new(idv_session.params, current_user)
def idv_form
@_idv_form ||= Idv::PhoneForm.new(idv_session.params, current_user)
end
end
end
28 changes: 21 additions & 7 deletions app/controllers/verify/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class SessionsController < ApplicationController
before_action :confirm_idv_attempts_allowed
before_action :confirm_idv_needed
before_action :confirm_step_needed, except: [:destroy]
before_action :initialize_idv_session, only: [:create]
before_action :submit_idv_form, only: [:create]

delegate :attempts_exceeded?, to: :step, prefix: true

Expand All @@ -18,7 +20,7 @@ def new

def create
result = step.submit
analytics.track_event(Analytics::IDV_BASIC_INFO_SUBMITTED, result.to_h)
analytics.track_event(Analytics::IDV_BASIC_INFO_SUBMITTED_VENDOR, result.to_h)

if result.success?
process_success
Expand All @@ -35,6 +37,13 @@ def destroy

private

def submit_idv_form
result = idv_form.submit(profile_params)
analytics.track_event(Analytics::IDV_BASIC_INFO_SUBMITTED_FORM, result.to_h)

process_failure unless result.success?
end

def step_name
:sessions
end
Expand All @@ -45,9 +54,9 @@ def confirm_step_needed

def step
@_step ||= Idv::ProfileStep.new(
idv_form: idv_profile_form,
idv_form_params: profile_params,
idv_session: idv_session,
params: profile_params
vendor_params: idv_session.vendor_params
)
end

Expand All @@ -68,7 +77,7 @@ def process_success
end

def process_failure
if step.duplicate_ssn?
if idv_form.duplicate_ssn?
flash[:error] = t('idv.errors.duplicate_ssn')
redirect_to verify_session_dupe_path
else
Expand All @@ -81,16 +90,21 @@ def view_model(error: nil)
Verify::SessionsNew.new(
error: error,
remaining_attempts: remaining_idv_attempts,
idv_form: idv_profile_form
idv_form: idv_form
)
end

def remaining_idv_attempts
Idv::Attempter.idv_max_attempts - current_user.idv_attempts
end

def idv_profile_form
@_idv_profile_form ||= Idv::ProfileForm.new((idv_session.params || {}), current_user)
def idv_form
@_idv_form ||= Idv::ProfileForm.new((idv_session.params || {}), current_user)
end

def initialize_idv_session
idv_session.params.merge!(profile_params)
idv_session.applicant = idv_session.vendor_params
end

def profile_params
Expand Down
12 changes: 6 additions & 6 deletions app/forms/idv/profile_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def submit(params)
FormResponse.new(success: valid?, errors: errors.messages)
end

def duplicate_ssn?
return true if any_matching_ssn_signatures?(ssn_signature)
return true if ssn_is_duplicate_with_old_key?
end

private

attr_writer(*Pii::Attributes.members)
Expand All @@ -61,12 +66,7 @@ def ssn_signature(key = Pii::Fingerprinter.current_key)
end

def ssn_is_unique
errors.add :ssn, I18n.t('idv.errors.duplicate_ssn') if ssn_is_duplicate?
end

def ssn_is_duplicate?
return true if any_matching_ssn_signatures?(ssn_signature)
return true if ssn_is_duplicate_with_old_key?
errors.add :ssn, I18n.t('idv.errors.duplicate_ssn') if duplicate_ssn?
end

def ssn_is_duplicate_with_old_key?
Expand Down
9 changes: 6 additions & 3 deletions app/services/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ def uuid
EMAIL_CONFIRMATION = 'Email Confirmation'.freeze
EMAIL_CONFIRMATION_RESEND = 'Email Confirmation requested due to invalid token'.freeze
IDV_BASIC_INFO_VISIT = 'IdV: basic info visited'.freeze
IDV_BASIC_INFO_SUBMITTED = 'IdV: basic info submitted'.freeze
IDV_BASIC_INFO_SUBMITTED_FORM = 'IdV: basic info form submitted'.freeze
IDV_BASIC_INFO_SUBMITTED_VENDOR = 'IdV: basic info vendor submitted'.freeze
IDV_MAX_ATTEMPTS_EXCEEDED = 'IdV: max attempts exceeded'.freeze
IDV_FINAL = 'IdV: final resolution'.freeze
IDV_FINANCE_CCN_VISIT = 'IdV: finance ccn visited'.freeze
IDV_FINANCE_CONFIRMATION = 'IdV: finance confirmation'.freeze
IDV_FINANCE_CONFIRMATION_FORM = 'IdV: finance confirmation form'.freeze
IDV_FINANCE_CONFIRMATION_VENDOR = 'IdV: finance confirmation vendor'.freeze
IDV_FINANCE_OTHER_VISIT = 'IdV: finance other visited'.freeze
IDV_INTRO_VISIT = 'IdV: intro visited'.freeze
IDV_PHONE_CONFIRMATION = 'IdV: phone confirmation'.freeze
IDV_PHONE_CONFIRMATION_FORM = 'IdV: phone confirmation form'.freeze
IDV_PHONE_CONFIRMATION_VENDOR = 'IdV: phone confirmation vendor'.freeze
IDV_PHONE_RECORD_VISIT = 'IdV: phone of record visited'.freeze
IDV_REVIEW_COMPLETE = 'IdV: review complete'.freeze
IDV_REVIEW_VISIT = 'IdV: review info visited'.freeze
Expand Down
17 changes: 2 additions & 15 deletions app/services/idv/financials_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def submit
if complete?
@success = true
idv_session.financials_confirmation = true
idv_session.params = idv_form.idv_params
idv_session.params = idv_form_params
else
@success = false
idv_session.financials_confirmation = false
Expand All @@ -13,29 +13,16 @@ def submit
FormResponse.new(success: success, errors: errors)
end

def form_valid_but_vendor_validation_failed?
form_valid? && !vendor_validation_passed?
end

private

attr_reader :success

def complete?
form_valid? && vendor_validation_passed?
vendor_validation_passed?
end

def vendor_validator_class
Idv::FinancialsValidator
end

def vendor_reasons
vendor_validator_result.reasons if form_valid?
end

def vendor_params
finance_type = idv_form.finance_type
{ finance_type => idv_form.idv_params[finance_type] }
end
end
end
16 changes: 2 additions & 14 deletions app/services/idv/phone_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,20 @@ def submit
FormResponse.new(success: complete?, errors: errors)
end

def form_valid_but_vendor_validation_failed?
form_valid? && !vendor_validation_passed?
end

private

def complete?
form_valid? && vendor_validation_passed?
vendor_validation_passed?
end

def vendor_validator_class
Idv::PhoneValidator
end

def vendor_params
idv_form.phone
end

def vendor_reasons
vendor_validator_result.reasons if form_valid?
end

def update_idv_session
idv_session.phone_confirmation = true
idv_session.address_verification_mechanism = :phone
idv_session.params = idv_form.idv_params
idv_session.params = idv_form_params
end
end
end
Loading