Skip to content

Commit

Permalink
Review comments.
Browse files Browse the repository at this point in the history
Style updates.
  • Loading branch information
jmax-gsa committed Dec 4, 2024
1 parent cd1f017 commit 8acfc9b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
32 changes: 12 additions & 20 deletions app/controllers/concerns/idv/document_capture_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,25 @@ def handle_stored_result(user: current_user, store_in_session: true)
flash[:success] = t('doc_auth.headings.capture_complete')
successful_response
else
extra = { stored_result_present: stored_result.present? }
failure(nil, extra)
FormResponse.new(
{
success: false,
errors: error_hash(message),
extra: { stored_result_present: stored_result.present? },
},
)
end
end

def successful_response
FormResponse.new(success: true)
end

# copied from Flow::Failure module
def failure(message = nil, extra = nil)
form_response_params = { success: false }
form_response_params[:errors] = make_error_hash(message)
form_response_params[:extra] = extra unless extra.nil?
FormResponse.new(**form_response_params)
end

def make_error_hash(message)
Rails.logger.info("make_error_hash: stored_result: #{stored_result.inspect}")

error_hash = { message: message || I18n.t('doc_auth.errors.general.network_error') }

if stored_result&.errors&.has_key?(:socure)
error_hash[:socure] = stored_result.errors[:socure]
end

error_hash
def error_hash(message)
{
message: message || I18n.t('doc_auth.errors.general.network_error'),
socure: stored_result&.errors[:socure],
}
end

def extract_pii_from_doc(user, store_in_session: false)
Expand Down
9 changes: 6 additions & 3 deletions app/presenters/socure_error_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,19 @@ def heading_string_for(error_code)

def error_string_for(error_code)
if error_code == :network
t('doc_auth.errors.general.new_network_error')
elsif remapped_error(error_code) == 'underage' # special handling because it says 'Login.gov'
return t('doc_auth.errors.general.new_network_error')
end

remapped_error_code = remapped_error(error_code)
if remapped_error_code == 'underage' # special handling because it says 'Login.gov'
I18n.t('doc_auth.errors.underage', app_name: APP_NAME)
else
# i18n-tasks-use t('doc_auth.errors.unreadable_id')
# i18n-tasks-use t('doc_auth.errors.unaccepted_id_type')
# i18n-tasks-use t('doc_auth.errors.expired_id')
# i18n-tasks-use t('doc_auth.errors.low_resolution')
# i18n-tasks-use t('doc_auth.errors.id_not_found')
I18n.t("doc_auth.errors.#{remapped_error(error_code)}")
I18n.t("doc_auth.errors.#{remapped_error_code}")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class DocvResultResponse < DocAuth::Response
def initialize(http_response:,
biometric_comparison_required: false)
@http_response = http_response

@biometric_comparison_required = biometric_comparison_required
@pii_from_doc = read_pii

Expand Down

0 comments on commit 8acfc9b

Please sign in to comment.