"use server"; import { redirect } from "next/navigation"; import { getUserByEmail, verifyPassword, createSession } from "../../lib/auth"; import { getSession } from "../../lib/auth"; export default async function LoginPage({ searchParams, }: { searchParams: Promise<{ error?: string }>; }) { const session = await getSession(); if (session) redirect("/tenants"); const { error } = await searchParams; return (

Rikx Beheer

{ "use server"; const email = formData.get("email") as string; const password = formData.get("password") as string; const user = getUserByEmail(email); if (!user || !verifyPassword(password, user.password_hash)) { redirect("/login?error=1"); } await createSession({ userId: user.id, email: user.email, name: user.name }); redirect("/tenants"); }} className="flex flex-col gap-4 bg-white dark:bg-zinc-900 p-8 rounded-xl border border-zinc-200 dark:border-zinc-800" > {error && (

Ongeldig e-mailadres of wachtwoord.

)}
); }