Fix server action structuur in login en tenants pagina's

Inline server actions in page components veroorzaken runtime errors.
Verplaatst naar aparte actions.ts / logout.ts bestanden.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Maarten Elsenaar
2026-09-15 13:34:40 +02:00
parent 8ad282aad8
commit abf4b48af1
4 changed files with 29 additions and 22 deletions
+15
View File
@@ -0,0 +1,15 @@
"use server";
import { redirect } from "next/navigation";
import { getUserByEmail, verifyPassword, createSession } from "../../lib/auth";
export async function login(formData: FormData) {
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");
}