diff --git a/components/UserManager.tsx b/components/UserManager.tsx index 7e31861..0cc4491 100644 --- a/components/UserManager.tsx +++ b/components/UserManager.tsx @@ -10,6 +10,7 @@ interface UserForm { full_name: string; role: Role; password: string; // bei Bearbeitung optional (leer = unverändert) + passwordRepeat: string; } const EMPTY_FORM: UserForm = { @@ -18,6 +19,7 @@ const EMPTY_FORM: UserForm = { full_name: "", role: "staff", password: "", + passwordRepeat: "", }; const ROLE_LABELS: Record = { @@ -74,6 +76,10 @@ export default function UserManager() { async function save(e: React.FormEvent) { e.preventDefault(); if (!form) return; + if (form.password && form.password !== form.passwordRepeat) { + setError("Die Passwörter stimmen nicht überein."); + return; + } const ok = form.id ? await callApi("PATCH", { id: form.id, @@ -186,6 +192,25 @@ export default function UserManager() { autoComplete="new-password" /> + {(!form.id || form.password) && ( +
+ + + setForm({ ...form, passwordRepeat: e.target.value }) + } + minLength={8} + required={!form.id || !!form.password} + autoComplete="new-password" + /> +
+ )}