Skip to content

Commit 8420f9b

Browse files
VIA-172 AJ/AS Handling client side session polling
1 parent 645d0f4 commit 8420f9b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/app/layout.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { InactivityDialog } from "@src/app/_components/inactivity/InactivityDialog";
44
import SkipLink from "@src/app/_components/nhs-frontend/SkipLink";
5+
import { WARNING_TIME_MS } from "@src/utils/auth/inactivity-timer";
56
import React, { JSX } from "react";
67
import "@public/nhsuk-frontend-9.1.0/css/nhsuk-9.1.0.min.css";
78
import "@public/nhsapp-frontend-2.3.0/nhsapp-2.3.0.min.css";
@@ -14,6 +15,13 @@ export default function RootLayout({
1415
}: Readonly<{
1516
children: React.ReactNode;
1617
}>): JSX.Element {
18+
// This is the polling time for the session on client side,
19+
// so that the client can react to session expiry.
20+
// The session expiry is handled by the server.
21+
// The value is set to 10 seconds less than the warning time.
22+
// This is to ensure that the warning dialog is only shown when user is authenticated.
23+
const SESSION_REFETCH_SECONDS = Math.floor(WARNING_TIME_MS / 1000) - 10;
24+
1725
return (
1826
<html lang="en">
1927
<head>
@@ -74,7 +82,7 @@ export default function RootLayout({
7482

7583
<body>
7684
<SkipLink />
77-
<SessionProvider>
85+
<SessionProvider refetchInterval={SESSION_REFETCH_SECONDS}>
7886
<InactivityDialog />
7987
<div className="nhsuk-width-container ">{children}</div>
8088
</SessionProvider>

0 commit comments

Comments
 (0)