mirror of
https://github.com/GlueOps/autoglue.git
synced 2026-02-13 12:50:05 +01:00
14 lines
352 B
TypeScript
14 lines
352 B
TypeScript
import { Navigate, Outlet, useLocation } from "react-router-dom"
|
|
|
|
import { useAuth } from "@/hooks/use-auth.ts"
|
|
|
|
export const ProtectedRoute = () => {
|
|
const { authed } = useAuth()
|
|
const loc = useLocation()
|
|
|
|
if (!authed) {
|
|
return <Navigate to={`/login?to=${encodeURIComponent(loc.pathname + loc.search)}`} replace />
|
|
}
|
|
return <Outlet />
|
|
}
|