-
Notifications
You must be signed in to change notification settings - Fork 167
LG-3207: incorporate selfie in document capture step #3929
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
Changes from all commits
2377849
5076079
5a293c8
477229c
1f331d7
393c156
753d2fa
4bc7b00
3d5b1d4
7116c4e
d8c5194
4a5f38b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,22 @@ def post_back_image(image:, instance_id:) | |
| ).fetch | ||
| end | ||
|
|
||
| def post_images(front_image:, back_image:, instance_id: nil) | ||
| def post_selfie(image:, instance_id:) | ||
| get_face_image_response = Requests::GetFaceImageRequest.new(instance_id: instance_id).fetch | ||
| return get_face_image_response unless get_face_image_response.success? | ||
|
|
||
| facial_match_response = Requests::FacialMatchRequest.new( | ||
| selfie_image: image, | ||
| document_face_image: get_face_image_response.image, | ||
| ).fetch | ||
| liveness_response = Requests::LivenessRequest.new(image: image).fetch | ||
|
|
||
| merge_facial_match_and_liveness_response(facial_match_response, liveness_response) | ||
| end | ||
|
|
||
| # rubocop:disable Metrics/AbcSize | ||
| def post_images(front_image:, back_image:, selfie_image:, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can drop the instance ID here, right? |
||
| liveness_checking_enabled: nil, instance_id: nil) | ||
| document = create_document | ||
| return failure(document.errors.first, document.to_h) unless document.success? | ||
|
|
||
|
|
@@ -29,26 +44,22 @@ def post_images(front_image:, back_image:, instance_id: nil) | |
| back_response = post_back_image(image: back_image, instance_id: instance_id) | ||
| response = merge_post_responses(front_response, back_response) | ||
|
|
||
| check_results(response, instance_id) | ||
| results = check_results(response, instance_id) | ||
|
|
||
| if results.success? && liveness_checking_enabled | ||
| pii = results.pii_from_doc | ||
| selfie_response = post_selfie(image: selfie_image, instance_id: instance_id) | ||
| Acuant::Responses::ResponseWithPii.new(selfie_response, pii) | ||
| else | ||
| results | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this line is uncovered. I think it makes sense for us to drop in a unit test for what happens if posting the selfie fails. |
||
| end | ||
| end | ||
| # rubocop:enable Metrics/AbcSize | ||
|
|
||
| def get_results(instance_id:) | ||
| Requests::GetResultsRequest.new(instance_id: instance_id).fetch | ||
| end | ||
|
|
||
| def post_selfie(instance_id:, image:) | ||
| get_face_image_response = Requests::GetFaceImageRequest.new(instance_id: instance_id).fetch | ||
| return get_face_image_response unless get_face_image_response.success? | ||
|
|
||
| facial_match_response = Requests::FacialMatchRequest.new( | ||
| selfie_image: image, | ||
| document_face_image: get_face_image_response.image, | ||
| ).fetch | ||
| liveness_response = Requests::LivenessRequest.new(image: image).fetch | ||
|
|
||
| merge_facial_match_and_liveness_response(facial_match_response, liveness_response) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def merge_post_responses(front_response, back_response) | ||
|
|
@@ -80,7 +91,7 @@ def check_results(post_response, instance_id) | |
|
|
||
| def fetch_doc_auth_results(instance_id) | ||
| results_response = get_results(instance_id: instance_id) | ||
| handle_document_verification_failure(results_response) unless results_response.success? | ||
| return handle_document_verification_failure(results_response) unless results_response.success? | ||
|
|
||
| results_response | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| module Acuant | ||
| module Responses | ||
| class ResponseWithPii < Acuant::Response | ||
| def initialize(acuant_response, pii) | ||
| super( | ||
| success: acuant_response.success?, | ||
| errors: acuant_response.errors, | ||
| exception: acuant_response.exception, | ||
| extra: acuant_response.extra, | ||
| ) | ||
| @pii = pii | ||
| end | ||
|
|
||
| def pii_from_doc | ||
| @pii | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <% if flow_session[:notice].present? %> | ||
| <div> | ||
| <%= flow_session[:notice].html_safe %> | ||
| </div> | ||
| <% end %> |
Uh oh!
There was an error while loading. Please reload this page.