Add WebAuthn support for admin login and kiosk mode

This commit is contained in:
2026-07-26 21:12:59 +02:00
parent 3c8d9297d7
commit 2b85152bb9
13 changed files with 466 additions and 9 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ import { hashSync } from "bcryptjs";
import { redirect, unstable_rethrow } from "next/navigation";
import { requireAdminUser } from "@/lib/auth";
import { db, initDatabase, transaction } from "@/lib/db";
import { idValue, passwordValue, roleValue, text } from "@/lib/validation";
import { idValue, passwordValue, roleValue, usernameValue } from "@/lib/validation";
import type { UserRole } from "@/lib/types";
function go(kind: "error" | "success", message: string): never {
@@ -23,7 +23,7 @@ export async function createUserAction(formData: FormData) {
await requireAdminUser();
initDatabase();
try {
const name = text(formData, "name", { required: true, max: 100 });
const name = usernameValue(formData, "name");
const existing = db
.prepare("SELECT 1 FROM users WHERE name = ? COLLATE NOCASE AND active = 1")
.get(name);