From d6036462efedba96f9d0ee2a4480d86778eadd37 Mon Sep 17 00:00:00 2001 From: hunterckx <118154470+hunterckx@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:31:17 -0700 Subject: [PATCH] feat: enable more reliable timeout handling with nextauth (#178) --- src/providers/nextAuthAuthentication/provider.tsx | 4 +++- src/providers/nextAuthAuthentication/types.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/providers/nextAuthAuthentication/provider.tsx b/src/providers/nextAuthAuthentication/provider.tsx index 3f37ab31..52b1e120 100644 --- a/src/providers/nextAuthAuthentication/provider.tsx +++ b/src/providers/nextAuthAuthentication/provider.tsx @@ -13,6 +13,7 @@ import { NextAuthAuthenticationProviderProps } from "./types"; export function NextAuthAuthenticationProvider({ children, + refetchInterval = 0, session, timeout, }: NextAuthAuthenticationProviderProps): JSX.Element { @@ -23,6 +24,7 @@ export function NextAuthAuthenticationProvider({ const { isAuthenticated } = authState; const { callbackUrl } = useSessionCallbackUrl(); useSessionIdleTimer({ + crossTab: true, disabled: !isAuthenticated, onIdle: () => { service.requestLogout({ callbackUrl, redirect: true }); @@ -31,7 +33,7 @@ export function NextAuthAuthenticationProvider({ }); useSessionAuth({ authReducer, authenticationReducer }); return ( - + {children} diff --git a/src/providers/nextAuthAuthentication/types.ts b/src/providers/nextAuthAuthentication/types.ts index 0351e7fb..02239de5 100644 --- a/src/providers/nextAuthAuthentication/types.ts +++ b/src/providers/nextAuthAuthentication/types.ts @@ -3,6 +3,7 @@ import { ReactNode } from "react"; export interface NextAuthAuthenticationProviderProps { children: ReactNode | ReactNode[]; + refetchInterval?: number; session?: Session | null; timeout?: number; }