VIA-942: Enforce Session Expiry Reliably After 10 Minutes of Inactivity#708
Merged
liming-cheung-nhs merged 13 commits intomainfrom May 5, 2026
Merged
VIA-942: Enforce Session Expiry Reliably After 10 Minutes of Inactivity#708liming-cheung-nhs merged 13 commits intomainfrom
liming-cheung-nhs merged 13 commits intomainfrom
Conversation
… recently called Precommit hooks bypassed; this is a work in progress commit WIP commit: contains * A Server Action to set the flag cookie * Calling the server action from the user-logout method * cherck the flag in getToken Issue under investigation 1. getToken will return null, but the MyVaccines app then currently tries to redirect the user to NHS App because they are not authenticated, meaning the user will never see the logout / session timeout screens. (at present this throws a cors error in the browser and the user never actually gets to NHS app but this is a quirk and the underlying issue still needs fixing; the user shouldnt be redirected at all for this part of the journey. The network tab shows the cors error and an error would be logged in our service logs).
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
terence-sheppard-nhs
previously approved these changes
Apr 29, 2026
There was a problem hiding this comment.
Pull request overview
Implements a short-lived “signout flag” cookie to prevent session refresh logic from re-authenticating a user immediately after logout/inactivity timeout, improving enforcement of 10-minute inactivity expiry.
Changes:
- Add
__Secure-signoutcookie constant and document it in the cookies policy table. - Set the signout-flag cookie during logout and check it in the NextAuth
jwt/getTokencallback to returnnullfor recently-signed-out sessions. - Add/extend unit tests for the new logout flow, cookie setting, and token callback behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/constants.ts | Adds constant for the new signout-flag cookie name. |
| src/utils/auth/user-logout.ts | Converts logout to a server action, wraps in request-scoped storage, and sets signout-flag cookie before signing out. |
| src/utils/auth/user-logout.test.ts | Updates mocks and adds assertions for flag cookie + request-scoped wrapper usage. |
| src/utils/auth/setSignOutFlagCookie.ts | New server action to set a short-lived signout-flag cookie tied to the session id. |
| src/utils/auth/setSignOutFlagCookie.test.ts | New unit test validating the signout cookie is set as expected. |
| src/utils/auth/callbacks/get-token.ts | Reads signout-flag + session-id cookies to short-circuit and return null after recent signout. |
| src/utils/auth/callbacks/get-token.test.ts | Adds tests ensuring getToken returns null when signout flag matches current session. |
| src/app/our-policies/cookies-policy/CookiesTable.tsx | Documents the new __Secure-signout cookie and its purpose/expiry. |
| src/app/our-policies/cookies-policy/CookiesTable.test.tsx | Updates expectations to include the new cookie row and timing. |
| src/app/_components/inactivity/InactivityDialog.test.tsx | Adjusts mocking for updated logout module usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <copilot@github.com>
sophie-poole-nhs
previously approved these changes
Apr 30, 2026
terence-sheppard-nhs
previously approved these changes
Apr 30, 2026
Co-authored-by: Copilot <copilot@github.com>
413fe4b to
ddf571b
Compare
Co-authored-by: Copilot <copilot@github.com>
kieran-broomhall-nhs
approved these changes
May 5, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Testing on deployed to sandpit personal workspace
30/04/2026
I was getting this Client side error- UNHANDLED_PROMISE_REJECT_ERROR on logout when put
signoutand cookie set in server.signoutneeds to be in client given current UI implementation - see comment in code. The error went away when movedsignoutfrom server.Note: Existing issue under investigation:
getTokenwill return null, but the MyVaccines app then currently tries to redirect the user to NHS App because they are not authenticated, meaning the user will never see the logout / session timeout screens. (at present this throws a cors error in the browser and the user never actually gets to NHS app but this is a quirk and the underlying issue still needs fixing; the user shouldnt be redirected at all for this part of the journey. The network tab shows the cors error and an error would be logged in our service logs).Context
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.