feat(web): return-to-destination on auth redirect; logout pending state (#48)

This commit is contained in:
2026-06-08 15:06:50 +02:00
parent ec6e90ef5b
commit af3f1a5367
4 changed files with 38 additions and 8 deletions
+6 -2
View File
@@ -1,14 +1,18 @@
import { Navigate, Outlet } from "react-router-dom";
import { Navigate, Outlet, useLocation } from "react-router-dom";
import { useMe } from "../api/queries";
import { AppShellSkeleton } from "@/components/ui/skeletons";
export function RequireAuth() {
const { data: user, isLoading } = useMe();
const location = useLocation();
if (isLoading) return <AppShellSkeleton />;
if (!user) return <Navigate to="/login" replace />;
if (!user) {
const from = encodeURIComponent(location.pathname + location.search);
return <Navigate to={`/login?from=${from}`} replace />;
}
return <Outlet />;
}