feat(web): add same-origin SPA authentication

This commit is contained in:
shaggy (mosaic-dev box)
2026-08-09 20:00:22 -05:00
parent 068d0f9b1c
commit 46d68e1ff4
20 changed files with 987 additions and 143 deletions
+16 -5
View File
@@ -1,12 +1,23 @@
import type { ReactElement } from 'react';
import { Outlet } from 'react-router-dom';
// P1 shells: session-aware redirects arrive with the reworked auth client in P2.
import { Navigate, Outlet } from 'react-router-dom';
import { useSession } from '@/lib/auth-client';
export function GuestGuard(): ReactElement {
return <Outlet />;
const { data: session } = useSession();
return session ? <Navigate to="/chat" replace /> : <Outlet />;
}
export function AuthGuard(): ReactElement {
return <Outlet />;
const { data: session, isPending } = useSession();
if (isPending) {
return (
<div className="flex min-h-screen items-center justify-center">
<div className="text-sm text-text-muted">Loading...</div>
</div>
);
}
return session ? <Outlet /> : <Navigate to="/login" replace />;
}