This commit is contained in:
admin
2026-09-03 22:02:52 +09:00
commit 659725de15
90 changed files with 2840 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import { Navigate, Outlet, useLocation } from "react-router-dom";
import { useAuth } from "./use-auth";
export function RequireAuth() {
const { isLoading, user } = useAuth();
const location = useLocation();
if (isLoading) {
return <div className="rounded-xl border border-slate-200 bg-white p-8 text-sm text-slate-600 shadow-sm">Loading session...</div>;
}
if (!user) {
return <Navigate replace state={{ from: location.pathname }} to="/login" />;
}
return <Outlet />;
}