-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- configure session timeout warning in frontend/themes/gov-uk/client-js/session-timeout-dialog.js - add frontend/template-partials/partials/session-timeout-warning.html - amend frontend/template-partials/partials/page.html to include session timeout warning in pages with forms. - add styling for session timeout warning - add leave form button in dialog box which resets session and goes to exit page informing user info has not been saved. This is for non save and return forms. - create session timeout component exit page customisable and session timeout warning dialog content customisable - add JSDoc and try/catch block to session timeout warning component - add hof logger to session timeout warning component - add session timeout warning component documentation to readme - amend sub heading levels for components in readme - amend confirmation page so it doesn't show popup - amend pr template name so it is picked up - add tests - update change log - update yarn.lock
- Loading branch information
1 parent
a135ac9
commit db0b465
Showing
24 changed files
with
997 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* | ||
* @fileOverview | ||
* Provides custom behavior for handling session timeout warnings and exit actions. This includes | ||
* - Resetting the session if the user exits due to a session timeout. | ||
* - Customizing the session timeout warning dialog content. | ||
* - Setting custom content and titles on the exit page. | ||
* | ||
* @module SessionTimeoutWarningBehavior | ||
* @requires ../../config/hof-defaults | ||
* @param {Class} superclass - The class to be extended. | ||
* @returns {Class} - The extended class with session timeout handling functionality. | ||
*/ | ||
|
||
'use strict'; | ||
const config = require('../../config/hof-defaults'); | ||
const logger = require('../../lib/logger')(config); | ||
|
||
module.exports = superclass => class extends superclass { | ||
configure(req, res, next) { | ||
try { | ||
// Reset the session if the user chooses to exit on session timeout warning | ||
if (req.form.options.route === '/exit') { | ||
req.sessionModel.reset(); | ||
logger.log('info', 'Session has been reset on exit'); | ||
} | ||
return super.configure(req, res, next); | ||
} catch (error) { | ||
logger.error('Error during session reset:', error); | ||
return next(error); // Pass the error to the next middleware for centralised handling | ||
} | ||
} | ||
|
||
locals(req, res) { | ||
// set the custom session dialog message | ||
const superLocals = super.locals(req, res); | ||
if (res.locals.sessionTimeoutWarningContent === true) { | ||
superLocals.dialogTitle = true; | ||
superLocals.dialogText = true; | ||
superLocals.timeoutContinueButton = true; | ||
superLocals.dialogExitLink = true; | ||
} | ||
|
||
// set the content on /exit page | ||
if (req.form.options.route === '/exit' && config.exitFormContent === true) { | ||
superLocals.exitFormContent = true; | ||
return superLocals; | ||
} else if (req.form.options.route === '/exit' && config.exitFormContent === false) { | ||
superLocals.header = req.translate('exit.header'); | ||
superLocals.title = req.translate('exit.title'); | ||
superLocals.message = req.translate('exit.message'); | ||
return superLocals; | ||
} | ||
return superLocals; | ||
} | ||
}; |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"header": "You have left this form", | ||
"title": "You have left this form", | ||
"message": "We have cleared your information to keep it secure. Your information has not been saved." | ||
} |
This file contains 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,6 +1,19 @@ | ||
{{<partials-page}} | ||
{{$page-content}} | ||
{{<layout}} | ||
{{$journeyHeader}} | ||
{{#t}}journey.header{{/t}} | ||
{{/journeyHeader}} | ||
|
||
{{$propositionHeader}} | ||
{{> partials-navigation}} | ||
{{/propositionHeader}} | ||
|
||
{{$header}} | ||
{{header}} | ||
{{/header}} | ||
|
||
{{$content}} | ||
{{>partials-confirmation-alert}} | ||
{{#markdown}}what-happens-next{{/markdown}} | ||
{{/page-content}} | ||
{{/partials-page}} | ||
{{/content}} | ||
{{/layout}} | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{<layout}} | ||
{{$header}} | ||
{{header}} | ||
{{/header}} | ||
{{$content}} | ||
<h2 class="govuk-heading-m">{{#exitFormContent}}{{#t}}pages.exit.message{{/t}}{{/exitFormContent}}{{^exitFormContent}}{{#t}}{{message}}{{/t}}{{/exitFormContent}}</h2> | ||
<a href="/" class="govuk-button" role="button">{{#t}}buttons.start-again{{/t}}</a> | ||
{{/content}} | ||
{{/layout}} |
This file contains 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
Oops, something went wrong.