import { Navigate, Route, Routes, Link, useLocation, useNavigate } from 'react-router-dom' import { useAuth } from './auth' function Shell({ children, admin = false }: { children: React.ReactNode; admin?: boolean }) { const { user, signOut } = useAuth() return
CMS{user && !admin && }
{children}
} function Login({ admin = false }: { admin?: boolean }) { const { user, loading, error, signIn } = useAuth() const navigate = useNavigate() if (!admin && user) return if (loading) return

Checking your session…

return
{admin ? 'Administration' : 'Welcome'}

{admin ? 'Admin sign in' : 'Sign in to CMS'}

{admin ? 'Use your administrator account to continue.' : 'Sign in securely with your external identity provider.'}

{error &&

{error}

} {!admin && } {admin &&

Administrator authentication is handled by the backend.

} {admin && }
} function ProtectedTest() { const { user, loading } = useAuth() const location = useLocation() if (loading) return

Loading…

if (!user) return return
Authenticated

Test page

You are signed in and can access protected content.

{user.email ?? user.name ? `Signed in as ${user.email ?? user.name}` : 'Your session is active.'}
} export function App() { return } /> } /> } /> } /> }