Benutzerverwaltung: Passwort-Wiederholung gegen Tippfehler

Gilt beim Anlegen (Pflicht) und beim optionalen Passwort-Reset im
Bearbeiten-Formular.
This commit is contained in:
2026-07-18 00:46:39 +02:00
parent 675503e1f4
commit 00745ae48b
+26
View File
@@ -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<Role, string> = {
@@ -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"
/>
</div>
{(!form.id || form.password) && (
<div className="max-w-60">
<label className="label" htmlFor="user-password-repeat">
Passwort wiederholen
</label>
<input
id="user-password-repeat"
type="password"
className="input"
value={form.passwordRepeat}
onChange={(e) =>
setForm({ ...form, passwordRepeat: e.target.value })
}
minLength={8}
required={!form.id || !!form.password}
autoComplete="new-password"
/>
</div>
)}
<div className="flex gap-2">
<button type="submit" className="btn btn-add" disabled={busy}>
Speichern
@@ -221,6 +246,7 @@ export default function UserManager() {
full_name: p.full_name,
role: p.role,
password: "",
passwordRepeat: "",
})
}
>