From dc2f428a8a54f6b59a4a24dd3a80db43e1808b0a Mon Sep 17 00:00:00 2001 From: Loup Theron Date: Wed, 18 Sep 2024 16:45:07 +0200 Subject: [PATCH] Add event on token expired --- frontend/src/auth/hooks/useCustomAuth.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/auth/hooks/useCustomAuth.tsx b/frontend/src/auth/hooks/useCustomAuth.tsx index 418757bd1d..b19409c3c6 100644 --- a/frontend/src/auth/hooks/useCustomAuth.tsx +++ b/frontend/src/auth/hooks/useCustomAuth.tsx @@ -11,7 +11,7 @@ export function useCustomAuth(): { isLoading: boolean userAccount: UserAccountContextType | undefined } { - // `| undefined` because it's undefined if the OICD is disabled which is the case for Cypress tests + // `| undefined` because it's undefined if the OIDC is disabled which is the case for Cypress tests const auth = useAuth() as AuthContextProps | undefined const [userAuthorization, setUserAuthorization] = useState(undefined) @@ -47,8 +47,10 @@ export function useCustomAuth(): { useEffect( () => - // the `return` is important - addAccessTokenExpiring() returns a cleanup function - auth?.events?.addAccessTokenExpiring(() => { + // the `return` is important - addAccessTokenExpired() returns a cleanup function + auth?.events?.addAccessTokenExpired(() => { + // eslint-disable-next-line no-console + console.log('Renewing token...') auth?.signinSilent() }), [auth]