Skip to content

Allow user to stay on account locked page#804

Merged
monfresh merged 2 commits intomasterfrom
mb-account-locked-fix
Dec 6, 2016
Merged

Allow user to stay on account locked page#804
monfresh merged 2 commits intomasterfrom
mb-account-locked-fix

Conversation

@monfresh
Copy link
Contributor

@monfresh monfresh commented Dec 2, 2016

Why: For a better UX, we want to leave the user on the account
locked page for the duration of the lockout period.

How:

  • Reverse the order of events in handle_second_factor_locked_user.
    The reason is that application.html.slim wasn't called after signing
    the user out, and therefore the timeout JS was still active.
    By reversing the order, we force a new call to the layout template,
    which then sees that a current user does not exist, and therefore does
    not trigger the timeout JS.
  • Revert the change from current_user to user_fully_authenticated?
    in the application layout to allow users who only sign in with email and
    password to see the time out warning modal.

**Why**: For a better UX, we want to leave the user on the account
locked page for the duration of the lockout period.

**How**:
- Reverse the order of events in `handle_second_factor_locked_user`.
The reason is that application.html.slim wasn't called after signing
the user out, and therefore the timeout JS was still active.
By reversing the order, we force a new call to the layout template,
which then sees that a current user does not exist, and therefore does
not trigger the timeout JS.
- Revert the change from `current_user` to `user_fully_authenticated?`
in the application layout to allow users who only sign in with email and
password to see the time out warning modal.
@monfresh monfresh self-assigned this Dec 2, 2016
@monfresh monfresh added this to the Sprint 20 milestone Dec 2, 2016
end

scenario 'user who enters OTP incorrectly 3 times is locked out for OTP validity period' do
scenario 'user who enters OTP incorrectly 3 times is locked out for OTP validity period', js: true do
Copy link
Contributor

Choose a reason for hiding this comment

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

line length 😿

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here: 891890a

scenario 'user who enters OTP incorrectly 3 times is locked out for OTP validity period' do
scenario 'user who enters OTP incorrectly 3 times is locked out for OTP validity period', js: true do
allow(Figaro.env).to receive(:session_check_frequency).and_return('1')
allow(Figaro.env).to receive(:session_check_delay).and_return('2')
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not seeing how these additions are needed in this spec file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These settings are needed to make sure the test fails if the handle_second_factor_locked_user method is not doing the right thing. I made sure the test failed with the previous code before fixing it. Without these overrides, the default settings would apply, which would take too long to trigger the session timeout calls. The fact that the session timeout JS was still active after the lockout is what caused the bug I am fixing now. See my commit message for an explanation of the bug.

sign_in_user(user)
visit user_two_factor_authentication_path

expect(page).to have_css('#session-timeout-msg')
Copy link
Contributor

Choose a reason for hiding this comment

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

does this expectation test the change we are making in this PR?

we want to leave the user on the account locked page for the duration of the lockout period.

It seems like it might but I am not sure. Perhaps adding more info to the spec description would clarify?

Copy link
Contributor

Choose a reason for hiding this comment

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

The expectation seems correct, but I think the 'why' of this PR might be slightly confusing. It restores the session warning modal when the user has started the 2FA process, but not finished it.

When I updated the account locked screen, I removed that modal from the sign in flow entirely (i.e. a user will only see if after they have successfully 2FA'd).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This expectation is testing a separate change. I suppose I should have split them up. One change was fixing the bug that redirected the user to the sign in page after being on the lockout page for about a minute. This change here is to make sure the session timeout modal appears on the 2FA page, which was the previous behavior before @el-mapache changed it in #772, but we didn't have a test for it.

@el-mapache, correct me if I'm wrong, but it sounded like you made this change because you thought it had something to do with the redirection from the lockout page to the sign in page. Is that correct, or was there a separate reason for this change?

Copy link
Contributor

@el-mapache el-mapache Dec 5, 2016

Choose a reason for hiding this comment

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

I made the change because previously, on the account locked page, the user would be signed out and returned to the sign in screen early, as you note in your PR description.

When this happened, the session timeout modal would briefly appear. I used the user_fully_authenticated? method so that that session timeout wouldn't appear unless the user had successfully completed the 2FA process.

I thought this was acceptable behavior because the user would still have their session automatically expired if they left their 2FA process open for an extended period of time without completing the sign in process.

Sorry to make the extra work 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries. The change I made here will solve the problem you mentioned without having to change the conditional in application.html.slim. Only showing the timeout warning modal to fully authed users will negatively affect UX in my opinion, which is why I think we should revert it back.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, i agree! I was conflating that modal with a user being logged in, not just having an active session. Your solution is definitely cleaner since it uses the same logic we had and lets the framework render the correct partial based on the data it's provided.

@monfresh monfresh force-pushed the mb-account-locked-fix branch from 891890a to 35aab63 Compare December 2, 2016 21:29
@monfresh
Copy link
Contributor Author

monfresh commented Dec 5, 2016

@zachmargolis @jessieay Are my changes and responses satisfactory?

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

@monfresh LGTM! I don't have much context on the user flow/experience, but the rubies look good to me!

@jessieay
Copy link
Contributor

jessieay commented Dec 6, 2016

+1 to @zachmargolis !

@monfresh monfresh merged commit fdd0081 into master Dec 6, 2016
@monfresh monfresh deleted the mb-account-locked-fix branch December 6, 2016 18:27
amoose pushed a commit that referenced this pull request Feb 24, 2017
* Allow user to stay on account locked page

**Why**: For a better UX, we want to leave the user on the account
locked page for the duration of the lockout period.

**How**:
- Reverse the order of events in `handle_second_factor_locked_user`.
The reason is that application.html.slim wasn't called after signing
the user out, and therefore the timeout JS was still active.
By reversing the order, we force a new call to the layout template,
which then sees that a current user does not exist, and therefore does
not trigger the timeout JS.
- Revert the change from `current_user` to `user_fully_authenticated?`
in the application layout to allow users who only sign in with email and
password to see the time out warning modal.
amoose pushed a commit that referenced this pull request Feb 28, 2017
* Allow user to stay on account locked page

**Why**: For a better UX, we want to leave the user on the account
locked page for the duration of the lockout period.

**How**:
- Reverse the order of events in `handle_second_factor_locked_user`.
The reason is that application.html.slim wasn't called after signing
the user out, and therefore the timeout JS was still active.
By reversing the order, we force a new call to the layout template,
which then sees that a current user does not exist, and therefore does
not trigger the timeout JS.
- Revert the change from `current_user` to `user_fully_authenticated?`
in the application layout to allow users who only sign in with email and
password to see the time out warning modal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants