feat(web): wire auth pages with BetterAuth client and route guards
Connect login/register forms to BetterAuth signIn.email() and signUp.email() with error display, loading states, and disabled inputs during submission. Add AuthGuard (redirects unauthenticated users to /login) on dashboard routes and GuestGuard (redirects authenticated users to /chat) on auth routes. Sign out in topbar now redirects to /login. Refs #27 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
'use client';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useSession, signOut } from '@/lib/auth-client';
|
||||
|
||||
export function Topbar(): React.ReactElement {
|
||||
const { data: session } = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
async function handleSignOut(): Promise<void> {
|
||||
await signOut();
|
||||
router.replace('/login');
|
||||
}
|
||||
|
||||
return (
|
||||
<header className="sticky top-0 z-20 flex h-14 items-center justify-between border-b border-surface-border bg-surface-card/80 px-6 backdrop-blur-sm">
|
||||
@@ -17,7 +24,7 @@ export function Topbar(): React.ReactElement {
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => signOut()}
|
||||
onClick={handleSignOut}
|
||||
className="rounded-md px-3 py-1.5 text-sm text-text-muted transition-colors hover:bg-surface-elevated hover:text-text-primary"
|
||||
>
|
||||
Sign out
|
||||
|
||||
Reference in New Issue
Block a user