import { AuthLayout } from '@/ui/components/auth-layout' import { Button } from '@/ui/components/ui/button' import { authClient } from '@/ui/lib/auth-client' import { useAuthStore } from '@/ui/stores/auth' import { m } from '@/ui/paraglide/messages.js' import { createLazyFileRoute } from '@tanstack/react-router' import { Check, Key, Loader2, ShieldCheck, User, X } from 'lucide-react' import { useState } from 'react' export const Route = createLazyFileRoute('/consent')({ component: ConsentPage, }) function ConsentPage() { const search = Route.useSearch() const rawUser = useAuthStore((state) => state.user) const user = rawUser && typeof rawUser === 'object' ? (rawUser as { email?: string; name?: string }) : null const [loading, setLoading] = useState<'accept' | 'deny' | null>(null) const [error, setError] = useState(null) const clientId = search.client_id || 'MCP Client' const scopes = search.scope ? search.scope.split(' ') : ['mcp'] const handleConsent = async (accept: boolean) => { setLoading(accept ? 'accept' : 'deny') setError(null) try { const res = await authClient.oauth2.consent({ accept, }) if (res.data?.url) { window.location.href = res.data.url } else if (res.error) { setError(res.error.message || m.consent_failed()) setLoading(null) } } catch (err) { setError(err instanceof Error ? err.message : m.consent_failed()) setLoading(null) } } return (

{m.authorize_application()}

{m.authorize_application_subtitle()}

{error && (
{error}
)}
{m.application_client_id()} {clientId}
{user && (
{m.logged_in_as()} {user.email || user.name}
)}
{m.requested_permissions()}

{m.mcp_access_scope_desc()}

{scopes.map((s) => ( {s} ))}
) }