LG-6845: Fix "Try again" button and SSN "< Back" link/button for IPP Flow#6675
LG-6845: Fix "Try again" button and SSN "< Back" link/button for IPP Flow#6675
Conversation
…ley/lg-6845-fix-back-and-try-again
…ton and SSN "< Back" link/button for IPP Flow
| def exception | ||
| end |
There was a problem hiding this comment.
Thanks for adding this! I think it's good to include the method even if there's no logic associated with that action, for clarity / completeness.
Style nit: For body-less methods like this, the convention I've seen is...
| def exception | |
| end | |
| def exception; end |
There was a problem hiding this comment.
Updated body-less method to meet convention.
app/views/idv/shared/_back.html.erb
Outdated
| flow = local_assigns[:flow] | ||
| step = local_assigns[:action] || local_assigns[:step] | ||
| path = step ? idv_doc_auth_step_path(step: step) : go_back_path | ||
| path = (flow && step) ? method(:"idv_#{flow}_step_path").call(step: step) : go_back_path |
There was a problem hiding this comment.
In other places we've used the @step_url instance variable assigned by FLowStateMachine. Can we do that here as well, to make sure we're consistently using the flow's step_url configuration?
There was a problem hiding this comment.
The remote proofing address page didn't like using @step_url, so I made it support local_assigns[:step_url] as well.
| end | ||
|
|
||
| def set_try_again_path | ||
| if request.referer&.starts_with? idv_in_person_url |
There was a problem hiding this comment.
I don't have a lot of confidence in the referer attribute, since it's easy for it to get lost (e.g. does a reload retain referer? Not really sure tbh). I wonder if we could include a parameter in the URL when redirecting to these error pages in DocAuthBaseStep#idv_failure, then use that when determining the try_again_path.
Or, alternatively, we may be able to infer that the user is in the in-person flow if we user_session['idv/in_person'] is not empty.
There was a problem hiding this comment.
This seemed like it would work in most practical use cases & kept the referrer when I refreshed. I understand the concern, though, and refactored it accordingly.
- Switch to using @step_url in shared back button/link ERB template - Switch from referrer to query param for try again path
aduth
left a comment
There was a problem hiding this comment.
Couple comments to consider, but overall LGTM 👍
app/views/idv/shared/_ssn.html.erb
Outdated
| * success_alert_enabled: whether or not to display a "We've successfully verified your ID" success alert | ||
| * updating_ssn: true if the user is updating their SSN instead of providing it for the first time. This | ||
| will render a different page heading and different navigation buttons in the page footer | ||
| * flow: Current flow; used to go to the previous state in the correct flow with "Back" link |
There was a problem hiding this comment.
Where do we use this flow value?
There was a problem hiding this comment.
It was used to determine the current flow, but is no longer needed. Removed.
| redirect_to idv_session_errors_exception_url( | ||
| from: request.original_url, | ||
| ) |
There was a problem hiding this comment.
I was sorta hoping this could be a simple token like "doc_auth" vs. "in_person", though I guess that's not readily available without a bit of extra effort. I wonder if we'd have any issues like described in this StackOverflow comment using original_url ?
Alternatively, there are some ways we could get a token from e.g. self.class.name or @flow.class.name or @flow.controller.class.name, but if we did that, we might want to clean it up so that it's not a namespaced Ruby class name.
There was a problem hiding this comment.
Another thought could be to implement an abstract method or variable in VerifyBaseStep, implement that for each flow, and pass that through to or reference from idv_failure.
module Idv
module Steps
class DocAuthBaseStep < Flow::BaseStep
def idv_failure
# ...
redirect_to exception_url
end
def exception_url
idv_session_errors_exception_url
end
end
end
end
module Idv
module Steps
module Ipp
class VerifyStep < VerifyBaseStep
def exception_url
idv_session_errors_exception_url(flow: :in_person)
end
end
end
end
end
module Idv
module Steps
class VerifyStep < VerifyBaseStep
def exception_url
idv_session_errors_exception_url(flow: :doc_auth)
end
end
end
endThere was a problem hiding this comment.
I think this'd be easier to determine if there was an intermediate step in the class hierarchy for IPP, but seeing as there are shared steps I decided to reduce this to the path instead of the full URL to reduce the probability of the issue mentioned on SO.
There was a problem hiding this comment.
I think idv_failure living in DocAuthBaseStep is a bit misleading to how much it's actually shared. This method is only ever called as part of the "Verify" step. It should probably be moved into VerifyBaseStep.
I'm bumping into it as part of LG-6927, so I'll see about moving the method as part of that work.
The "Try Again" button on the exception/warning pages will now check the referrer for an IPP URL and provide an IPP index page redirect if one is found. The IPP "index" page always redirects to the current step of the IPP flow.
The "Back" link/button used by the IPP flow had the parent flow hardcoded, so I refactored it to accept the flow name as a symbol. The new
CancelUpdateSsnActionwas also required because the IPP flow stores session state inpii_from_userinstead ofpii_from_doc.