Add WebAuthn support for admin login and kiosk mode
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user