'use client' import { useState } from 'react' import { createAuthClient } from 'better-auth/react' import { magicLinkClient } from 'better-auth/client/plugins' const authClient = createAuthClient({ plugins: [magicLinkClient()], }) type Mode = 'password' | 'magic' export default function LoginPage() { const [mode, setMode] = useState('password') const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [sent, setSent] = useState(false) const [loading, setLoading] = useState(false) const [error, setError] = useState('') async function handleSubmit(e: React.FormEvent) { e.preventDefault() setLoading(true) setError('') if (mode === 'password') { const result = await authClient.signIn.email({ email, password, callbackURL: '/dashboard', }) setLoading(false) if (result.error) { setError(result.error.message ?? 'E-Mail oder Passwort falsch.') } else { window.location.href = '/dashboard' } } else { const result = await authClient.signIn.magicLink({ email, callbackURL: '/dashboard', }) setLoading(false) if (result.error) { setError(result.error.message ?? 'Ein Fehler ist aufgetreten.') } else { setSent(true) } } } return (
{/* Logo */}

InnungsApp

Verwaltungsportal für Innungen

{sent ? (

E-Mail gesendet

Login-Link an {email} gesendet. Bitte prüfen Sie Ihr Postfach.

) : ( <>

Anmelden

{/* Mode toggle */}
setEmail(e.target.value)} placeholder="admin@ihre-innung.de" className="w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-transparent" />
{mode === 'password' && (
setPassword(e.target.value)} placeholder="••••••••" className="w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-transparent" />
)} {error && (

{error}

)}
{mode === 'password' && (

Demo: admin@demo.de / demo1234

)} )}
) }