From 1745097d04087c5b9fa083eca3af1af5b547eaae Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Fri, 8 Apr 2022 11:24:10 +1000 Subject: [PATCH] fix unauthenticated users getting stuck on ProtectedRoutes --- src/contexts/AppContext.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/contexts/AppContext.tsx b/src/contexts/AppContext.tsx index 1eddfe536..881ce5ed8 100644 --- a/src/contexts/AppContext.tsx +++ b/src/contexts/AppContext.tsx @@ -81,7 +81,7 @@ export const AppProvider: React.FC = ({ children }) => { }; useEffect(() => { auth.onAuthStateChanged((auth) => { - if (auth) + if (auth) { auth.getIdTokenResult(true).then((results) => { setCurrentUser(auth); setAuthToken(results.token); @@ -90,6 +90,9 @@ export const AppProvider: React.FC = ({ children }) => { ); setUserClaims(results.claims); }); + } else { + setCurrentUser(auth); + } }); }, []);