From 4b71d81bde78d1a0d67fbe736873c43d67351297 Mon Sep 17 00:00:00 2001 From: Pedro Sanders Date: Sat, 25 Nov 2023 12:11:48 -0500 Subject: [PATCH] fix: add null check for initial login session --- mods/frontoffice/src/authentication.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mods/frontoffice/src/authentication.tsx b/mods/frontoffice/src/authentication.tsx index 033bfc1..e3290b1 100644 --- a/mods/frontoffice/src/authentication.tsx +++ b/mods/frontoffice/src/authentication.tsx @@ -123,6 +123,10 @@ export function AuthProvider({ children }: AuthProviderProps) { }; const isAdmin = (workspaceId: string) => { + if (!client) { + return; + } + const payload = jwtDecode(client?.getToken() as string) as { workspaces: { id: string; role: Role }[]; }; @@ -134,6 +138,10 @@ export function AuthProvider({ children }: AuthProviderProps) { }; useEffect(() => { + if (!client) { + return; + } + const tokenExpiration = jwtDecode(client?.getToken() as string) as { exp: number; };