Skip to content

Commit f009350

Browse files
committed
Fix: Login infinite loop bug
1 parent 01c61f2 commit f009350

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

course-matrix/frontend/src/components/login-route.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ interface AuthRouteProps {
1212
* Checks if a user session exists in localstorage. If so then redirect to dashboard.
1313
*/
1414
const LoginRoute: React.FC<AuthRouteProps> = ({ component: Component }) => {
15-
const user = localStorage.getItem("userInfo");
15+
const { data, isLoading, error } = useGetSessionQuery();
1616

17-
return user ? <Navigate to="/dashboard" replace /> : <Component />;
17+
return data?.user ? <Navigate to="/dashboard" replace /> : <Component />;
1818
};
1919

2020
export default LoginRoute;

0 commit comments

Comments
 (0)