'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; function authentikUrl() { const issuer = process.env.NEXT_PUBLIC_AUTHENTIK_ISSUER; const clientId = process.env.NEXT_PUBLIC_AUTHENTIK_CLIENT_ID; const base = process.env.NEXT_PUBLIC_BASE_URL ?? (typeof window !== 'undefined' ? window.location.origin : ''); if (!issuer || !clientId) return null; const params = new URLSearchParams({ response_type: 'code', client_id: clientId, redirect_uri: `${base}/api/auth/callback`, scope: 'openid email profile', }); return `${issuer}/application/o/authorize/?${params}`; } export default function LoginPage() { const router = useRouter(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const oidcUrl = typeof window !== 'undefined' ? authentikUrl() : null; const submit = async (e: React.FormEvent) => { e.preventDefault(); if (!username || !password) return; setLoading(true); setError(''); const res = await fetch('/api/auth/login', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ username, password }), }); if (res.ok) { router.push('/dashboard'); } else { const j = await res.json().catch(() => ({})); setError(j.error ?? 'Login failed'); setLoading(false); } }; return (
{/* brand */}
cvfs
Sign in to your account
{/* form card */}
setUsername(e.target.value)} placeholder="admin" />
setPassword(e.target.value)} placeholder="••••••••" />
{error && (
{error}
)}
{oidcUrl && ( <>

or
)}

cvfs — CV File System

); }