-
Notifications
You must be signed in to change notification settings - Fork 166
Pass analytics to StepInfo preconditions proc #11259
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
Closed
Closed
Changes from all commits
Commits
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
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
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
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
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 |
|---|---|---|
|
|
@@ -2,15 +2,54 @@ | |
|
|
||
| module Idv | ||
| class FlowPolicy | ||
| attr_reader :idv_session, :user | ||
| attr_reader :analytics, :idv_session, :user | ||
|
|
||
| FINAL = :final | ||
|
|
||
| def initialize(idv_session:, user:) | ||
| def initialize(analytics:, idv_session:, user:) | ||
| @analytics = analytics | ||
| @idv_session = idv_session | ||
| @user = user | ||
| end | ||
|
|
||
| def steps | ||
| @steps ||= { | ||
| root: Idv::StepInfo.new( | ||
| key: :root, | ||
| controller: AccountsController, | ||
| next_steps: [:welcome, :request_letter], | ||
| preconditions: ->(idv_session:, user:, analytics:) { true }, | ||
| undo_step: ->(idv_session:, user:) { true }, | ||
| ), | ||
| welcome: Idv::WelcomeController.step_info, | ||
| agreement: Idv::AgreementController.step_info, | ||
| how_to_verify: Idv::HowToVerifyController.step_info, | ||
| hybrid_handoff: Idv::HybridHandoffController.step_info, | ||
| link_sent: Idv::LinkSentController.step_info, | ||
| document_capture: Idv::DocumentCaptureController.step_info, | ||
| ipp_address: Idv::InPerson::AddressController.step_info, | ||
| ssn: Idv::SsnController.step_info, | ||
| ipp_ssn: Idv::InPerson::SsnController.step_info, | ||
| verify_info: Idv::VerifyInfoController.step_info, | ||
| ipp_verify_info: Idv::InPerson::VerifyInfoController.step_info, | ||
| address: Idv::AddressController.step_info, | ||
| phone: Idv::PhoneController.step_info, | ||
| phone_errors: Idv::PhoneErrorsController.step_info, | ||
| otp_verification: Idv::OtpVerificationController.step_info, | ||
| request_letter: Idv::ByMail::RequestLetterController.step_info, | ||
| enter_password: Idv::EnterPasswordController.step_info, | ||
| personal_key: Idv::PersonalKeyController.step_info, | ||
| }.freeze | ||
| end | ||
|
|
||
| def step_allowed?(key:) | ||
|
Contributor
Author
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. Changes to this one:
|
||
| steps[key].preconditions.call( | ||
| analytics: analytics, | ||
| idv_session: idv_session, | ||
| user: user, | ||
| ) | ||
| end | ||
|
|
||
| def controller_allowed?(controller:) | ||
| controller_name = controller < ApplicationController ? | ||
| StepInfo.full_controller_name(controller) : controller | ||
|
|
@@ -43,40 +82,6 @@ def latest_step(current_step: :root) | |
| current_step | ||
| end | ||
|
|
||
| def steps | ||
| { | ||
| root: Idv::StepInfo.new( | ||
| key: :root, | ||
| controller: AccountsController, | ||
| next_steps: [:welcome, :request_letter], | ||
| preconditions: ->(idv_session:, user:) { true }, | ||
| undo_step: ->(idv_session:, user:) { true }, | ||
| ), | ||
| welcome: Idv::WelcomeController.step_info, | ||
| agreement: Idv::AgreementController.step_info, | ||
| how_to_verify: Idv::HowToVerifyController.step_info, | ||
| hybrid_handoff: Idv::HybridHandoffController.step_info, | ||
| link_sent: Idv::LinkSentController.step_info, | ||
| document_capture: Idv::DocumentCaptureController.step_info, | ||
| ipp_address: Idv::InPerson::AddressController.step_info, | ||
| ssn: Idv::SsnController.step_info, | ||
| ipp_ssn: Idv::InPerson::SsnController.step_info, | ||
| verify_info: Idv::VerifyInfoController.step_info, | ||
| ipp_verify_info: Idv::InPerson::VerifyInfoController.step_info, | ||
| address: Idv::AddressController.step_info, | ||
| phone: Idv::PhoneController.step_info, | ||
| phone_errors: Idv::PhoneErrorsController.step_info, | ||
| otp_verification: Idv::OtpVerificationController.step_info, | ||
| request_letter: Idv::ByMail::RequestLetterController.step_info, | ||
| enter_password: Idv::EnterPasswordController.step_info, | ||
| personal_key: Idv::PersonalKeyController.step_info, | ||
| } | ||
| end | ||
|
|
||
| def step_allowed?(key:) | ||
| steps[key].preconditions.call(idv_session: idv_session, user: user) | ||
| end | ||
|
|
||
| def undo_steps_from!(key:) | ||
| return if key == FINAL | ||
|
|
||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to this method:
@steps ||=to the beginning so steps are cached.freezeto the object definitionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of the freeze? was code modifying this sneakily?