This commit is contained in:
2025-11-06 01:40:00 +01:00
parent de5f54f4bc
commit 602c5a40f1
108 changed files with 9859 additions and 1382 deletions

View File

@@ -0,0 +1,22 @@
import { Navigate, Outlet, useLocation } from "react-router-dom";
function getCookie(name: string): string | null {
const nameEQ = name + "=";
const ca = document.cookie.split(";").map((c) => c.trim());
for (const c of ca) {
if (c.indexOf(nameEQ) === 0) return decodeURIComponent(c.substring(nameEQ.length));
}
return null;
}
const ACCESS_COOKIE = "access_token";
export default function PrivateRoute() {
const location = useLocation();
const isLoggedIn = !!getCookie(ACCESS_COOKIE);
if (!isLoggedIn) {
return <Navigate to="/login" replace state={{ from: location }} />;
}
return <Outlet />;
}