-
Notifications
You must be signed in to change notification settings - Fork 166
LG-3022: extending auth clients to accept front/back DL images in one call. #3901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3eb347c
LG-3022: extending auth clients to accept all images in one call.
solipet 9fbae56
fleshed out spec
solipet 27d9192
got the js image previews working
solipet ba4adeb
rubocop
solipet 0a5c974
validate the auth results
solipet 10b7da4
specs
solipet 619933e
generate the instance_id and check the results within the acuant client
solipet 70994a9
addressing comments
solipet 643dffe
removing take_picture listener until we incorporate mobile/selfie
solipet 6319fb9
specs
solipet d73a702
expand code coverage
solipet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| module Idv | ||
| class DocumentCaptureForm | ||
| include ActiveModel::Model | ||
|
|
||
| ATTRIBUTES = %i[front_image front_image_data_url back_image back_image_data_url].freeze | ||
|
|
||
| attr_accessor :front_image, :front_image_data_url, :back_image, :back_image_data_url | ||
|
|
||
| validate :front_image_or_image_data_url_presence | ||
| validate :back_image_or_image_data_url_presence | ||
|
|
||
| def self.model_name | ||
| ActiveModel::Name.new(self, nil, 'Image') | ||
| end | ||
|
|
||
| def submit(params) | ||
| consume_params(params) | ||
|
|
||
| FormResponse.new(success: valid?, errors: errors.messages) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def front_image_or_image_data_url_presence | ||
| return if front_image.present? || front_image_data_url.present? | ||
| errors.add(:front_image, :blank) | ||
| end | ||
|
|
||
| def back_image_or_image_data_url_presence | ||
| return if back_image.present? || back_image_data_url.present? | ||
| errors.add(:back_image, :blank) | ||
| end | ||
|
|
||
| def consume_params(params) | ||
| params.each do |key, value| | ||
| raise_invalid_image_parameter_error(key) unless ATTRIBUTES.include?(key.to_sym) | ||
| send("#{key}=", value) | ||
| end | ||
| end | ||
|
|
||
| def raise_invalid_image_parameter_error(key) | ||
| raise ArgumentError, "#{key} is an invalid image attribute" | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,30 @@ | ||
| module Idv | ||
| module Steps | ||
| class DocumentCaptureStep < DocAuthBaseStep | ||
| def call; end | ||
| def call | ||
| response = post_images | ||
| if response.success? | ||
| save_proofing_components | ||
| extract_pii_from_doc(response) | ||
| else | ||
| handle_document_verification_failure(response) | ||
| end | ||
| end | ||
|
|
||
| def form_submit; end | ||
| private | ||
|
|
||
| def handle_document_verification_failure(response) | ||
| mark_step_incomplete(:document_capture) | ||
| extra = response.to_h.merge( | ||
| notice: I18n.t('errors.doc_auth.general_info'), | ||
| ) | ||
| failure(response.errors.first, extra) | ||
| end | ||
|
|
||
| def form_submit | ||
| Idv::DocumentCaptureForm.new.submit(permit(:front_image, :front_image_data_url, | ||
| :back_image, :back_image_data_url)) | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,71 @@ | ||
| <div id='document-capture-form'> | ||
| Form goes here | ||
| </div> | ||
|
|
||
| <div> | ||
| <% title t('doc_auth.titles.doc_auth') %> | ||
|
|
||
| <%= render 'idv/doc_auth/error_messages', flow_session: flow_session %> | ||
|
|
||
| <%= simple_form_for( | ||
| :doc_auth, | ||
| url: url_for, | ||
| method: 'PUT', | ||
| html: { autocomplete: 'off', role: 'form', class: 'mt2' } | ||
| ) do |f| %> | ||
| <%# ---- Front Image ----- %> | ||
| <%= render 'idv/doc_auth/front_of_state_id_image' %> | ||
|
|
||
| <h1 class='h3 my0'> | ||
| <%= t('doc_auth.headings.upload_front') %> | ||
| </h1> | ||
|
|
||
| <%= accordion('totp-info', t('doc_auth.tips.title_html'), | ||
| wrapper_css: 'my2 col-12 fs-16p') 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 %> | ||
|
|
||
| <%= f.input :front_image_data_url, as: :hidden %> | ||
| <%= render 'idv/doc_auth/notices', flow_session: flow_session %> | ||
| <%= f.input :front_image, label: false, as: :file, required: true, wrapper_class: 'mt3 sm-col-8' %> | ||
| <div class='my2' id='front_target'></div> | ||
|
|
||
|
|
||
| <%# ---- Back Image ----- %> | ||
| <%= render 'idv/doc_auth/back_of_state_id_image' %> | ||
|
|
||
| <h1 class='h3 my0'> | ||
| <%= t('doc_auth.headings.upload_back') %> | ||
| </h1> | ||
|
|
||
| <%= accordion('totp-info', t('doc_auth.tips.title_html'), | ||
| wrapper_css: 'my2 col-12 fs-16p') 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 %> | ||
|
|
||
| <%= f.input :back_image_data_url, as: :hidden %> | ||
| <%= render 'idv/doc_auth/notices', flow_session: flow_session %> | ||
| <%= f.input :back_image, label: false, as: :file, required: true, wrapper_class: 'mt3 sm-col-8' %> | ||
| <div class='my2' id='back_target'></div> | ||
|
|
||
| <%# ---- Selfie ----- %> | ||
|
|
||
|
|
||
| <%# ---- Selfie ----- %> | ||
|
|
||
| <div class='mt3'> | ||
| <%= render 'idv/doc_auth/submit_with_spinner' %> | ||
| </div> | ||
| <% end %> | ||
|
|
||
| <p class='mt3 mb0'><%= t('doc_auth.info.upload_image') %></p> | ||
|
|
||
| <%= render 'idv/doc_auth/start_over_or_cancel' %> | ||
| <%= javascript_pack_tag 'image-preview' %> | ||
| </div> | ||
| <%= javascript_pack_tag 'document-capture' %> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.