Skip to content

Commit

Permalink
fix unauthenticated users getting stuck on ProtectedRoutes
Browse files Browse the repository at this point in the history
  • Loading branch information
notsidney committed Apr 8, 2022
1 parent 70a1039 commit 1745097
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/contexts/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -90,6 +90,9 @@ export const AppProvider: React.FC = ({ children }) => {
);
setUserClaims(results.claims);
});
} else {
setCurrentUser(auth);
}
});
}, []);

Expand Down

0 comments on commit 1745097

Please sign in to comment.