-
Notifications
You must be signed in to change notification settings - Fork 167
LG-14753 Bug fix for sign-in page losing user progress #11783
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
45cb5fc
changelog: Bug Fixes, accessibility and authorization, modal has been…
kevinsmaster5 3fcfc01
refactor tests to account for modal changes
kevinsmaster5 7c33dc2
replace assumed translation key
kevinsmaster5 b389b8a
adds a translated string for sign-out/already signed out
kevinsmaster5 3e044a8
replace expected translation key in spec
kevinsmaster5 33b8668
back out of translation changes, revise spec expectations to capture …
kevinsmaster5 14f23bb
refactor session expiration TS to remove redundancy
kevinsmaster5 020b8da
fix regression for logged-in user timeout
kevinsmaster5 7a46929
move login page to its own ts file. reduce constant hammering at sess…
kevinsmaster5 f1a4e84
include a clearInterval when hiding the modal
kevinsmaster5 2e31f38
revise spec for changes to FE script
kevinsmaster5 d79d051
delete redundant test
kevinsmaster5 d5813d5
branch tests into create and sign in paths
kevinsmaster5 78cc1ae
add click cancel to sign in test
kevinsmaster5 f85d3d6
remove unneeded attributes and close up refresh and session extend in…
kevinsmaster5 c0c266a
clean up date object, fix overly redundant test setup
kevinsmaster5 f966b05
change to spec timeout_in
kevinsmaster5 3754685
translated text for email field finder
kevinsmaster5 1a4f116
provide calculated value for timeout
kevinsmaster5 a95ce99
remove static expected timeout value
kevinsmaster5 55c355a
provide session timeout and remove possibly flaky test element
kevinsmaster5 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,40 @@ | ||
| const expireConfig = document.getElementById('js-expire-session'); | ||
| import { extendSession } from '@18f/identity-session'; | ||
| import type { CountdownElement } from '@18f/identity-countdown/countdown-element'; | ||
| import type { ModalElement } from '@18f/identity-modal'; | ||
|
|
||
| if (expireConfig && expireConfig.dataset.sessionTimeoutIn) { | ||
| const sessionTimeoutIn = parseInt(expireConfig.dataset.sessionTimeoutIn, 10) * 1000; | ||
| const timeoutRefreshPath = expireConfig.dataset.timeoutRefreshPath || ''; | ||
| const warningEl = document.getElementById('session-timeout-cntnr')!; | ||
|
|
||
| setTimeout(() => { | ||
| const warning = Number(warningEl.dataset.warning!) * 1000; | ||
| const sessionsURL = warningEl.dataset.sessionsUrl!; | ||
| const sessionTimeout = Number(warningEl.dataset.sessionTimeoutIn!) * 1000; | ||
| const modal = document.querySelector<ModalElement>('lg-modal.session-timeout-modal')!; | ||
| const keepaliveEl = document.getElementById('session-keepalive-btn'); | ||
| const countdownEls: NodeListOf<CountdownElement> = modal.querySelectorAll('lg-countdown'); | ||
| const timeoutRefreshPath = warningEl.dataset.timeoutRefreshPath || ''; | ||
|
|
||
| let sessionExpiration = new Date(Date.now() + sessionTimeout); | ||
|
|
||
| function showModal() { | ||
| modal.show(); | ||
| countdownEls.forEach((countdownEl) => { | ||
| countdownEl.expiration = sessionExpiration; | ||
| countdownEl.start(); | ||
| }); | ||
| } | ||
|
|
||
| function keepalive() { | ||
| const isExpired = new Date() > sessionExpiration; | ||
| if (isExpired) { | ||
| document.location.href = timeoutRefreshPath; | ||
aduth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, sessionTimeoutIn); | ||
| } else { | ||
| modal.hide(); | ||
| sessionExpiration = new Date(Date.now() + sessionTimeout); | ||
|
|
||
| setTimeout(showModal, sessionTimeout - warning); | ||
| countdownEls.forEach((countdownEl) => countdownEl.stop()); | ||
| extendSession(sessionsURL); | ||
| } | ||
| } | ||
|
|
||
| keepaliveEl?.addEventListener('click', keepalive, false); | ||
| setTimeout(showModal, sessionTimeout - warning); | ||
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 |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| <%= tag.div id: 'js-expire-session', | ||
| <%= tag.div id: 'session-timeout-cntnr', | ||
| data: { | ||
| session_timeout_in: session_timeout_in, | ||
| timeout_refresh_path: timeout_refresh_path, | ||
| warning: warning, | ||
| sessions_url: api_internal_sessions_path, | ||
| } %> | ||
|
|
||
| <%= render(partial: 'session_timeout/warning', locals: { modal_presenter: modal }) %> | ||
| <%= javascript_packs_tag_once 'session-expire-session', preload_links_header: false %> |
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.
Uh oh!
There was an error while loading. Please reload this page.