Skip to content

LG-4305: Log new event in case of lockout from proofing (2)#4829

Merged
aduth merged 4 commits intomainfrom
aduth-lg-4305-log-throttle-2
Mar 29, 2021
Merged

LG-4305: Log new event in case of lockout from proofing (2)#4829
aduth merged 4 commits intomainfrom
aduth-lg-4305-log-throttle-2

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Mar 24, 2021

Originally: #4803

Why: As a login.gov developer, i want to see an event in the event log that indicates that a user was locked out for 6 hours from proofing along with the relevant data points that directly resulted in that lockout, so that I can troubleshoot any issues reported by end users and pinpoint exactly what caused the lock out.

Builds on (merges to) #4824

Cherry-picks from #4803

@aduth aduth marked this pull request as ready for review March 25, 2021 12:59
Base automatically changed from revert-4803-aduth-lg-4305-log-throttle to main March 25, 2021 14:41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add this to the index call as well. This case would only be hit if the user submitted the form while they're already throttled, but we don't show the form if they are.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add this to the index call as well. This case would only be hit if the user submitted the form while they're already throttled, but we don't show the form if they are.

Ah, gotcha, that makes sense. I'll update.

On a related topic, @amathews-fs and I had discussed a bit if we could log the event only at the point they're initially being redirected to the throttle, vs. each and every time they're presented with a throttle page. I thought that might be what was happening here, as far as being the throttled submission. It might just be simpler and most consistent to always log the throttle on every view, and group by user / session if we need to aggregate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not sure it's possible. Current flow is for it to render index when it fails the result, and if that's the final attempt before throttling, index is the only place to reliably catch it.

And actually now that I look at it closer, it's weirdly doing a render of :index when the result is not successful, when it should probably be a redirect...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add this to the index call as well. This case would only be hit if the user submitted the form while they're already throttled, but we don't show the form if they are.

Updated in 5dc89f7.

And actually now that I look at it closer, it's weirdly doing a render of :index when the result is not successful, when it should probably be a redirect...

Sounds like a correct assessment to me. Dunno if it makes sense here, but I included it in dd85512. Flash errors would be shown in the redirect, yeah? I don't feel the tests have great coverage for those, despite the test case claiming "to show errors". 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it uses flash.now[:error] instead of flash[:error] to make the render show the flash message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage was better than I expected, since it appeared to catch that. Should be better now in d129979, though I don't feel great about the chain of changes required with persisting errors that were previously read directly by the view from the prior form submission. 😬

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be ok 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it in the app. It seems to work fine, but only after I forcibly modify the code to trigger the validate_pending_profile validation, since from what I can tell, it's impossible for the user to actually trigger it, because its validation effectively occurs in a prior validation. We might want to clean this up (separately), though I guess it may be reasonable to have something explicitly checking the pending profile? 🤷

  1. validate :validate_otp
  2. def validate_otp
    return if otp.blank? || valid_otp?
  3. def valid_otp?
    otp.present? && gpo_confirmation_code.present?
  4. def gpo_confirmation_code
    return if otp.blank? || pending_profile.blank?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for above

aduth added 3 commits March 26, 2021 14:46
**Why**: As a login.gov developer, i want to see an event in the event log that indicates that a user was locked out for 6 hours from proofing along with the relevant data points that directly resulted in that lockout, so that I can troubleshoot any issues reported by end users and pinpoint exactly what caused the lock out.
**Why**: So throttled template would be rendered if failure results in throttle

See: #4829 (comment)
@aduth aduth force-pushed the aduth-lg-4305-log-throttle-2 branch from f38d186 to dd85512 Compare March 26, 2021 19:16
@aduth aduth merged commit b201a8d into main Mar 29, 2021
@aduth aduth deleted the aduth-lg-4305-log-throttle-2 branch March 29, 2021 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants