Skip to content
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

Updates timeout handling to match requirements #333

Merged
merged 4 commits into from
Jul 27, 2021
Merged

Conversation

lomky
Copy link
Contributor

@lomky lomky commented Jul 23, 2021

When the user has been on the site for ~25 minutes an alert appears letting them know they will be logged out in 5 minutes. Previously the user could acknowledge this alert and reset the timer. Now the user may navigate back to UI Home to refresh their session, or they can dismiss the modal to stay on the page, but will be redirected to login again regardless in 5 minutes.

===

Resolves #199

  • Update modal timeout of 30m to be fixed instead of resetting
  • Match wording from the Content Document
  • Update the button to return the user to UI Home
  • Changes are tested on Staging post-merge into main

@lomky lomky self-assigned this Jul 23, 2021
Comment on lines +19 to +25
// handy converter for Minutes -> Milliseconds
const ONE_MINUTE_MS = 60 * 1000

// keep times in human readable minutes
const REDIRECT_TIMER = 30
const WARNING_DURATION = 5
const WARNING_TIMER = REDIRECT_TIMER - WARNING_DURATION
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted these to human readable minutes, converting to milliseconds just in time

Comment on lines -25 to -31
useEffect(() => {
if (showWarningModal) {
const timer = setTimeout(() => {
setNumberOfMinutes(numberOfMinutes - 1)
}, 60 * 1000)
return () => clearTimeout(timer)
}
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 was just here twice. Oops 😅

}
}

function startOrUpdate() {
Copy link
Contributor Author

@lomky lomky Jul 23, 2021

Choose a reason for hiding this comment

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

The big change in this PR is this is no longer a loop that resets, but instead we only run once. So no longer any need to clear and reset our base state, and instead we need to just track if we're before warning, warning, or done warning.

showWarningModal tells us whether we're actively warning or not, and warned tells us whether we've warned or not.

Comment on lines +59 to +62
if (warningTimerId) {
clearTimeout(warningTimerId)
warningTimerId = null
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

clear our all timers related to the going-to-warn.

Comment on lines +65 to +67
function redirectToUIHome() {
const uioHomeLink = userArrivedFromUioMobile ? getUrl('uio-home-url-mobile') : getUrl('uio-home-url-desktop')
window.location.href = uioHomeLink || ''
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another change: instead of the button dismissing the modal, it lets the user head back to UI Home to keep their session active. This is only if they hit the button though - X'ing out the modal or clicking outside it lets them stay

Comment on lines 39 to 41
"warning": "To protect your information, you will be logged out in {{count}} minute if you do not continue",
"warning_plural": "To protect your information, you will be logged out in {{count}} minutes if you do not continue",
"button": "Return to UI Home"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated verbiage matches Content doc - and properly handles the plural!

Copy link
Contributor

@rocketnova rocketnova left a comment

Choose a reason for hiding this comment

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

@lomky I started to review this PR and then realized that my FE react knowledge just isn't quite strong enough to review TimeoutModal.tsx yet. Could you walk me through it synchronously?

components/TimeoutModal.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@kalvinwang kalvinwang left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for simplifying the code!

components/TimeoutModal.tsx Outdated Show resolved Hide resolved
components/TimeoutModal.tsx Outdated Show resolved Hide resolved
components/TimeoutModal.tsx Show resolved Hide resolved
@kalvinwang
Copy link
Contributor

kalvinwang commented Jul 26, 2021

does timeoutmodal not have a snapshot or is it just not included in this PR?

Copy link
Contributor

@rocketnova rocketnova left a comment

Choose a reason for hiding this comment

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

@lomky Thanks for walking me through TimeoutModal.tsx! This LGTM with a few minor changes:

  1. The modal sentence is missing a period.
  2. The modal bold is in the wrong font

Screen Shot 2021-07-26 at 11 57 29 AM

public/locales/en/common.json Outdated Show resolved Hide resolved
public/locales/es/common.json Show resolved Hide resolved
@lomky lomky merged commit 8a66ebf into main Jul 27, 2021
@lomky lomky deleted the kat/199_sessions branch July 27, 2021 14:12
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.

Update session handling to better match UIO timeouts
3 participants