Skip to content

Fix: [AEA-5850] - bug fix for unable to sign out of cis2 errors#2093

Open
jonathanwelch1-nhs wants to merge 1 commit intomainfrom
aea-5850-signout-failure-log
Open

Fix: [AEA-5850] - bug fix for unable to sign out of cis2 errors#2093
jonathanwelch1-nhs wants to merge 1 commit intomainfrom
aea-5850-signout-failure-log

Conversation

@jonathanwelch1-nhs
Copy link
Copy Markdown
Contributor

Summary

https://nhsd-jira.digital.nhs.uk/browse/AEA-5850

  • Routine Change

Details

Users were returning errors where they werent fully logged out of cis2.
Now handles logout more gracefully

Copilot AI review requested due to automatic review settings May 1, 2026 14:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves CIS2 logout robustness in the CPT UI by preventing requests to the CIS2 signout endpoint from being blocked when the user session is already expired/unavailable, avoiding “unable to sign out” errors.

Changes:

  • Wraps fetchAuthSession() in a try/catch in the Axios request interceptor and allows CIS2 signout requests to proceed without an ID token.
  • Updates Authorization header assignment to use a stringified token consistently.
  • Adds unit tests covering fetchAuthSession rejection behavior for CIS2 signout vs non-signout endpoints.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/cpt-ui/src/helpers/axios.tsx Makes token retrieval failure non-fatal for CIS2 signout requests while keeping other endpoints protected.
packages/cpt-ui/tests/axios.test.tsx Adds regression tests ensuring CIS2 signout isn’t blocked when fetchAuthSession throws, and that other endpoints still fail.


const authSession = await fetchAuthSession()
const idToken = authSession.tokens?.idToken
const isAmplifyHostRequest = config.url?.includes("/api/cis2-signout") ?? false
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

isAmplifyHostRequest is checking for the CIS2 signout endpoint (/api/cis2-signout), so the name is misleading now that it controls auth-abort behaviour. Rename it to something like isCis2SignoutRequest (or similar) to make the intent clear.

Copilot generated this review using guidance from repository custom instructions.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 2026

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.

2 participants