Skip to content

Commit 0e42a2b

Browse files
Fix: [AEA-5481] - Ensure logged in users are redirected if they navigate to site/ (#1121)
## Summary - Routine Change ### Details Ensure logged in users are redirected if they navigate to site/. Cloudfront redirects work and get the user to site/, but existing behaviour was to present page not found, change the behaviour to forward the user to kick off the search functionality. --------- Signed-off-by: Connor Avery <[email protected]>
1 parent 6b35c60 commit 0e42a2b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.github/workflows/run_regression_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ jobs:
7070
run: |
7171
if [[ "$TARGET_ENVIRONMENT" != "prod" && "$TARGET_ENVIRONMENT" != "ref" ]]; then
7272
# this should be the tag of the tests you want to run
73-
REGRESSION_TEST_REPO_TAG=v3.0.0
73+
REGRESSION_TEST_REPO_TAG=v3.1.0
7474
7575
# this should be the tag of the regression test workflow you want to run
7676
# This will normally be the same as REGRESSION_TEST_REPO_TAG
77-
REGRESSION_TEST_WORKFLOW_TAG=v3.0.0
77+
REGRESSION_TEST_WORKFLOW_TAG=v3.1.0
7878
7979
curl https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/tags/${REGRESSION_TEST_WORKFLOW_TAG}/scripts/run_regression_tests.py -o run_regression_tests.py
8080
poetry install

packages/cpt-ui/src/App.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Routes, Route} from "react-router-dom"
2-
import {AuthProvider} from "@/context/AuthProvider"
1+
import {Routes, Route, Navigate} from "react-router-dom"
2+
import {AuthProvider, useAuth} from "@/context/AuthProvider"
33
import {AccessProvider} from "@/context/AccessProvider"
44
import {SearchProvider} from "@/context/SearchProvider"
55
import {PatientDetailsProvider} from "./context/PatientDetailsProvider"
@@ -23,6 +23,14 @@ import PrivacyNoticePage from "./pages/PrivacyNoticePage"
2323

2424
import {FRONTEND_PATHS} from "@/constants/environment"
2525

26+
const RootRoute = () => {
27+
const {isSignedIn} = useAuth()
28+
29+
return isSignedIn
30+
? <Navigate to={FRONTEND_PATHS.SEARCH_BY_PRESCRIPTION_ID} replace />
31+
: <NotFoundPage />
32+
}
33+
2634
export default function App() {
2735
return (
2836
<AuthProvider>
@@ -38,7 +46,7 @@ export default function App() {
3846
<Route path="cookies-selected" element={<CookieSettingsPage />} />
3947

4048
{/* Your existing routes */}
41-
<Route index element={<NotFoundPage />} />
49+
<Route index element={<RootRoute />} />
4250
<Route path="*" element={<NotFoundPage />} />
4351
<Route path={FRONTEND_PATHS.LOGIN} element={<LoginPage />} />
4452
<Route path={FRONTEND_PATHS.LOGOUT} element={<LogoutPage />} />

0 commit comments

Comments
 (0)