From 532fffca2770b912fcad647ebaf0f6f2c7fda5fd Mon Sep 17 00:00:00 2001 From: "Cross, Liam (UG - Comp Sci & Elec Eng)" <lc01383@surrey.ac.uk> Date: Tue, 2 Apr 2024 17:00:42 +0000 Subject: [PATCH] Refresh now properly considers auth on protected routes --- client/src/providers/AuthProvider.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/providers/AuthProvider.tsx b/client/src/providers/AuthProvider.tsx index d6dd383..9b92384 100644 --- a/client/src/providers/AuthProvider.tsx +++ b/client/src/providers/AuthProvider.tsx @@ -10,7 +10,7 @@ export interface IUser { } function AuthProvider({ children }: { children: ReactNode }) { - const [auth, setAuth] = useState(false); + const [auth, setAuth] = useState(true); const [user, setUser] = useState<IUser>(); const data = useLoaderData() as IUser | null; @@ -18,6 +18,9 @@ function AuthProvider({ children }: { children: ReactNode }) { if (data) { giveAuth(); setUser(data); + } else { + removeAuth(); + setUser(undefined); } }, []); -- GitLab