Next.js 15 App Router mit öffentlicher Übersicht und geschütztem Admin-Bereich zur Pflege von Datenschutzerklärungen nach Art. 12ff. DSGVO. - Oberfläche auf Basis von shadcn/ui, Inter lokal eingebunden - Prisma/SQLite, Auth.js mit Credentials-Provider und Rollen - Massenimport der Merkblätter des Amtes Leezen aus PDF - Docker-Image (standalone) und Gitea-Workflow zur Veröffentlichung Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
134 lines
4.3 KiB
TypeScript
134 lines
4.3 KiB
TypeScript
"use client"
|
|
|
|
import { useState } from "react"
|
|
import { getSession, signIn } from "next-auth/react"
|
|
import { useRouter } from "next/navigation"
|
|
import { AlertCircle, Eye, EyeOff, ShieldCheck } from "lucide-react"
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
import { Input } from "@/components/ui/input"
|
|
import { Label } from "@/components/ui/label"
|
|
import { ThemeToggle } from "@/components/theme-toggle"
|
|
|
|
export default function SignInPage() {
|
|
const [email, setEmail] = useState("")
|
|
const [password, setPassword] = useState("")
|
|
const [showPassword, setShowPassword] = useState(false)
|
|
const [isLoading, setIsLoading] = useState(false)
|
|
const [error, setError] = useState("")
|
|
const router = useRouter()
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault()
|
|
setIsLoading(true)
|
|
setError("")
|
|
|
|
try {
|
|
const result = await signIn("credentials", {
|
|
email,
|
|
password,
|
|
redirect: false,
|
|
})
|
|
|
|
if (result?.error) {
|
|
setError("Ungültige Anmeldedaten")
|
|
} else {
|
|
const session = await getSession()
|
|
if (session) {
|
|
router.push("/admin")
|
|
router.refresh()
|
|
}
|
|
}
|
|
} catch {
|
|
setError("Ein Fehler ist aufgetreten")
|
|
} finally {
|
|
setIsLoading(false)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex min-h-screen flex-col bg-background">
|
|
<div className="flex justify-end p-4">
|
|
<ThemeToggle />
|
|
</div>
|
|
|
|
<main className="flex flex-1 items-center justify-center px-6 pb-20">
|
|
<div className="w-full max-w-sm space-y-6">
|
|
<div className="flex flex-col items-center gap-3 text-center">
|
|
<div className="flex size-11 items-center justify-center rounded-xl bg-brand text-brand-foreground">
|
|
<ShieldCheck className="size-6" />
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<h1 className="text-xl leading-none font-semibold tracking-tight">
|
|
Syncova Policies
|
|
</h1>
|
|
<p className="text-sm text-muted-foreground">
|
|
Anmeldung zum Admin-Portal
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<form onSubmit={handleSubmit} className="space-y-4">
|
|
{error && (
|
|
<div className="flex items-center gap-2.5 rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive">
|
|
<AlertCircle className="size-4 shrink-0" />
|
|
{error}
|
|
</div>
|
|
)}
|
|
|
|
<div className="space-y-2">
|
|
<Label htmlFor="email">E-Mail-Adresse</Label>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
autoComplete="username"
|
|
value={email}
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
placeholder="name@firma.de"
|
|
required
|
|
disabled={isLoading}
|
|
/>
|
|
</div>
|
|
|
|
<div className="space-y-2">
|
|
<Label htmlFor="password">Passwort</Label>
|
|
<div className="relative">
|
|
<Input
|
|
id="password"
|
|
type={showPassword ? "text" : "password"}
|
|
autoComplete="current-password"
|
|
value={password}
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
placeholder="••••••••"
|
|
required
|
|
disabled={isLoading}
|
|
className="pr-10"
|
|
/>
|
|
<Button
|
|
type="button"
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
className="absolute top-1/2 right-0.5 -translate-y-1/2 text-muted-foreground"
|
|
onClick={() => setShowPassword(!showPassword)}
|
|
disabled={isLoading}
|
|
>
|
|
{showPassword ? <EyeOff /> : <Eye />}
|
|
<span className="sr-only">Passwort anzeigen</span>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
{isLoading ? "Anmeldung…" : "Anmelden"}
|
|
</Button>
|
|
</form>
|
|
|
|
<p className="text-center text-xs text-muted-foreground">
|
|
Zugang nur für berechtigte Administratoren
|
|
</p>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
)
|
|
}
|