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
10 changes: 5 additions & 5 deletions app/assets/javascripts/i18n-strings.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ window.LoginGov = window.LoginGov || {};
'doc_auth.headings.document_capture',
'doc_auth.headings.upload_front',
'doc_auth.headings.upload_back',
'doc_auth.instructions.document_capture_header_text',
'doc_auth.instructions.document_capture_id_text1',
'doc_auth.instructions.document_capture_id_text2',
'doc_auth.instructions.document_capture_id_text3',
'doc_auth.instructions.document_capture_id_text4',
'doc_auth.tips.document_capture_header_text',
'doc_auth.tips.document_capture_id_text1',
'doc_auth.tips.document_capture_id_text2',
'doc_auth.tips.document_capture_id_text3',
'doc_auth.tips.document_capture_id_text4',
'users.personal_key.close'
] %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ function DocumentsStep({ value, onChange }) {
<>
<PageHeading>{t('doc_auth.headings.document_capture')}</PageHeading>
<p className="margin-top-2 margin-bottom-0">
{t('doc_auth.instructions.document_capture_header_text')}
{t('doc_auth.tips.document_capture_header_text')}
</p>
<ul>
<li>{t('doc_auth.instructions.document_capture_id_text1')}</li>
<li>{t('doc_auth.instructions.document_capture_id_text2')}</li>
<li>{t('doc_auth.instructions.document_capture_id_text3')}</li>
{!isMobile && <li>{t('doc_auth.instructions.document_capture_id_text4')}</li>}
<li>{t('doc_auth.tips.document_capture_id_text1')}</li>
<li>{t('doc_auth.tips.document_capture_id_text2')}</li>
<li>{t('doc_auth.tips.document_capture_id_text3')}</li>
{!isMobile && <li>{t('doc_auth.tips.document_capture_id_text4')}</li>}
</ul>
{DOCUMENT_SIDES.map((side) => {
const label = t(`doc_auth.headings.upload_${side}`);
Expand Down
22 changes: 15 additions & 7 deletions app/javascript/packs/image-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ function imagePreview() {

document.addEventListener('DOMContentLoaded', imagePreview);

function imagePreviewFunction(imageId, imageTarget) {
function imagePreviewFunction(imageType) {
const imageId = `doc_auth_${imageType}_image`;
const imageIdSelector = `#${imageId}`;
const takeImageSelector = `#take_${imageType}_picture`;
const targetIdSelector = `#${imageType}_target`;

return function () {
$(imageId).on('change', function (event) {
$(takeImageSelector).on('click', function () {
document.getElementById(imageId).click();
});
$(imageIdSelector).on('change', function (event) {
$('.simple_form .alert-error').hide();
$('.simple_form .alert-notice').hide();
const { files } = event.target;
Expand All @@ -43,19 +51,19 @@ function imagePreviewFunction(imageId, imageTarget) {
const ratio = this.height / this.width;
img.width = displayWidth;
img.height = displayWidth * ratio;
$(imageTarget).html(img);
$(targetIdSelector).html(img);
};
img.src = file.target.result;
$(imageTarget).html(img);
$(targetIdSelector).html(img);
};
reader.readAsDataURL(image);
});
};
}

const frontImagePreview = imagePreviewFunction('#doc_auth_front_image', '#front_target');
const backImagePreview = imagePreviewFunction('#doc_auth_back_image', '#back_target');
const selfieImagePreview = imagePreviewFunction('#doc_auth_selfie_image', '#selfie_target');
const frontImagePreview = imagePreviewFunction('front');
const backImagePreview = imagePreviewFunction('back');
const selfieImagePreview = imagePreviewFunction('selfie');

document.addEventListener('DOMContentLoaded', frontImagePreview);
document.addEventListener('DOMContentLoaded', backImagePreview);
Expand Down
1 change: 1 addition & 0 deletions app/services/idv/flows/doc_auth_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DocAuthFlow < Flow::BaseFlow
link_sent: Idv::Steps::LinkSentStep,
email_sent: Idv::Steps::EmailSentStep,
document_capture: Idv::Steps::DocumentCaptureStep,
mobile_document_capture: Idv::Steps::MobileDocumentCaptureStep,
front_image: Idv::Steps::FrontImageStep,
back_image: Idv::Steps::BackImageStep,
mobile_front_image: Idv::Steps::MobileFrontImageStep,
Expand Down
1 change: 1 addition & 0 deletions app/services/idv/steps/doc_auth_base_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def mark_document_capture_or_image_upload_steps_complete
mark_step_complete(:mobile_back_image)
else
mark_step_complete(:document_capture)
mark_step_complete(:mobile_document_capture)
end
end

Expand Down
36 changes: 36 additions & 0 deletions app/services/idv/steps/mobile_document_capture_step.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module Idv
module Steps
class MobileDocumentCaptureStep < DocAuthBaseStep
def call
response = post_images
if response.success?
save_proofing_components
extract_pii_from_doc(response)
else
handle_document_verification_failure(response)
end
end

private

def handle_document_verification_failure(response)
mark_step_incomplete(:mobile_document_capture)
notice = if liveness_checking_enabled?
{ notice: I18n.t('errors.doc_auth.document_capture_info_with_selfie_html') }
else
{ notice: I18n.t('errors.doc_auth.document_capture_info_html') }
end
extra = response.to_h.merge(notice)
failure(response.errors.first, extra)
end

def form_submit
Idv::DocumentCaptureForm.
new(liveness_checking_enabled: liveness_checking_enabled?).
submit(permit(:front_image, :front_image_data_url,
:back_image, :back_image_data_url,
:selfie_image, :selfie_image_data_url))
end
end
end
end
2 changes: 2 additions & 0 deletions app/services/idv/steps/upload_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def desktop
mark_step_complete(:email_sent)
mark_step_complete(:mobile_front_image)
mark_step_complete(:mobile_back_image)
mark_step_complete(:mobile_document_capture)
end

def mobile
Expand All @@ -44,6 +45,7 @@ def mobile
mark_step_complete(:email_sent)
mark_step_complete(:front_image)
mark_step_complete(:back_image)
mark_step_complete(:document_capture)
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/views/idv/doc_auth/_start_over_or_cancel.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<br/>
<%= button_to(
t('doc_auth.buttons.start_over'),
idv_doc_auth_step_path(step: :reset),
method: :put,
class: 'btn btn-link',
form_class: 'inline-block'
form_class: 'inline-block mt3'
) %>
<%= render 'shared/cancel', link: idv_cancel_path %>
88 changes: 49 additions & 39 deletions app/views/idv/doc_auth/document_capture.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
<div id="document-capture-form">
<%= render 'idv/doc_auth/error_messages', flow_session: flow_session %>

<h1>
<h1 class="h3 my0">
<% if liveness_checking_enabled? %>
<%= t('doc_auth.headings.document_capture_with_selfie_html') %>
<%= t('doc_auth.headings.document_capture_heading_with_selfie_html') %>
<% else %>
<%= t('doc_auth.headings.document_capture_html') %>
<%= t('doc_auth.headings.document_capture_heading_html') %>
<% end %>
</h1>

<%= render 'idv/doc_auth/document_capture_notices', flow_session: flow_session %>

<%= simple_form_for(
:doc_auth,
url: url_for,
Expand All @@ -31,69 +29,81 @@
) do |f| %>
<%# ---- Front Image ----- %>

<hr class="mt3 mb3"/>
<div class="front-image">
<h2>
<%= t('doc_auth.headings.upload_front_html') %>
</h2>

<%= accordion('totp-info-front', t('doc_auth.tips.title_html')) do %>
<%= render 'idv/doc_auth/tips_and_sample' %>
<div class='center'>
<%= image_tag(asset_url('state-id-sample-front.jpg'), height: 338, width: 450) %>
</div>
<% end %>
<p class="mt2 mb0"><%= t('doc_auth.tips.document_capture_header_text') %></p>
<ul>
<li><%= t('doc_auth.tips.document_capture_id_text1') %></li>
<li><%= t('doc_auth.tips.document_capture_id_text2') %></li>
<li><%= t('doc_auth.tips.document_capture_id_text3') %></li>
<li><%= t('doc_auth.tips.document_capture_id_text4') %></li>
</ul>

<div class="front-image mt2">
<p>
<strong>
<%= t('doc_auth.headings.document_capture_front') %><br/>
</strong>
<%= t('doc_auth.tips.document_capture_hint') %>
</p>

<%= f.input :front_image_data_url, as: :hidden %>
<%= f.input :front_image, label: false, as: :file, required: true, wrapper_class: 'mt3 sm-col-8' %>
<%= f.input :front_image, label: false, as: :file, required: true %>
<div class='my2' id='front_target'></div>
</div>

<%# ---- Back Image ----- %>

<hr class="mt3 mb3"/>
<div class="back-image">
<h2>
<%= t('doc_auth.headings.upload_back_html') %>
</h2>

<%= accordion('totp-info-back', t('doc_auth.tips.title_html')) do %>
<%= render 'idv/doc_auth/tips_and_sample' %>
<div class='center'>
<%= image_tag(asset_url('state-id-sample-back.jpg'), height: 338, width: 450) %>
</div>
<% end %>
<div class="back-image mt3">
<p>
<strong>
<%= t('doc_auth.headings.document_capture_back') %><br/>
</strong>
<%= t('doc_auth.tips.document_capture_hint') %>
</p>

<%= f.input :back_image_data_url, as: :hidden %>
<%= f.input :back_image, label: false, as: :file, required: true, wrapper_class: 'mt3 sm-col-8' %>
<%= f.input :back_image, label: false, as: :file, required: true %>
<div class='my2' id='back_target'></div>
</div>

<%# ---- Selfie ----- %>
<% if liveness_checking_enabled? %>
<hr class="mt3 mb3"/>
<div class="selfie">
<h2>
<%= t('doc_auth.headings.selfie') %>
</h2>
<p><%= t('doc_auth.instructions.document_capture_selfie_instructions') %></p>

<p class="mt2 mb0"><%= t('doc_auth.tips.document_capture_header_text') %></p>
<ul>
<li><%= t('doc_auth.tips.document_capture_selfie_text1') %></li>
<li><%= t('doc_auth.tips.document_capture_selfie_text2') %></li>
<li><%= t('doc_auth.tips.document_capture_selfie_text3') %></li>
</ul>

<p class='mt3'>
<strong>
<%= t('doc_auth.headings.document_capture_selfie') %><br/>
</strong>
<%= t('doc_auth.tips.document_capture_hint') %>
</p>

<%= f.input :selfie_image_data_url, as: :hidden %>
<%= f.input :selfie_image, label: false, as: :file, required: true, wrapper_class: 'mt3 sm-col-8' %>
<%= f.input :selfie_image, label: false, as: :file, required: true %>
<div class='my2' id='selfie_target'></div>
</div>
<% end %>

<%# ---- Submit ----- %>

<div class='mt3'>
<div class='mt4 mb4'>
<%= render 'idv/doc_auth/submit_with_spinner' %>
</div>
<% end %>
<% end %> <%# end simple_form_for %>

<p class='mt3 mb0'><%= t('doc_auth.info.upload_image') %></p>
<p class='mt3 mb0'><%= t('doc_auth.info.document_capture_upload_image') %></p>

<%= javascript_pack_tag 'image-preview' %>
</div>
<%= render 'idv/doc_auth/start_over_or_cancel' %>
<%= javascript_pack_tag 'document-capture' %>
<% unless Figaro.env.document_capture_react_enabled == 'false' %>
<%= javascript_pack_tag 'document-capture' %>
<% end %>
<% end %>
Loading