| @@ -5,7 +5,7 @@ import { useState } from "react"; | |||||
| import { Navigate, useLocation } from "react-router-dom"; | import { Navigate, useLocation } from "react-router-dom"; | ||||
| export default function AuthGuard({ children }: HasChildren) { | export default function AuthGuard({ children }: HasChildren) { | ||||
| const { authenticated } = useAuth(); | |||||
| const { authenticated, initialized } = useAuth(); | |||||
| const { pathname } = useLocation(); | const { pathname } = useLocation(); | ||||
| @@ -13,6 +13,10 @@ export default function AuthGuard({ children }: HasChildren) { | |||||
| null | null | ||||
| ); | ); | ||||
| if (!initialized) { | |||||
| return null; | |||||
| } | |||||
| if (!authenticated) { | if (!authenticated) { | ||||
| if (pathname !== requestedLocation) { | if (pathname !== requestedLocation) { | ||||
| setRequestedLocation(pathname); | setRequestedLocation(pathname); | ||||