diff --git a/frontend/src/modals/bellcloud/users/CreateUserModal.jsx b/frontend/src/modals/bellcloud/users/CreateUserModal.jsx index 1d5ba4d..5e5b915 100644 --- a/frontend/src/modals/bellcloud/users/CreateUserModal.jsx +++ b/frontend/src/modals/bellcloud/users/CreateUserModal.jsx @@ -11,12 +11,13 @@ export default function CreateUserModal({ open, onClose, onCreated }) { const [email, setEmail] = useState('') const [displayName, setDisplayName] = useState('') const [password, setPassword] = useState('') + const [confirm, setConfirm] = useState('') const [saving, setSaving] = useState(false) const [error, setError] = useState('') useEffect(() => { if (!open) return - setEmail(''); setDisplayName(''); setPassword(''); setError('') + setEmail(''); setDisplayName(''); setPassword(''); setConfirm(''); setError('') }, [open]) const handleCreate = async () => { @@ -29,6 +30,10 @@ export default function CreateUserModal({ open, onClose, onCreated }) { setError('Password must be at least 6 characters.') return } + if (password !== confirm) { + setError('Passwords do not match.') + return + } setSaving(true) try { const created = await api.post('/users', { @@ -88,6 +93,16 @@ export default function CreateUserModal({ open, onClose, onCreated }) { placeholder="Min. 6 characters" hint="Used to sign into the mobile app immediately." /> + setConfirm(e.target.value)} + required + placeholder="Re-enter password" + error={confirm && password !== confirm ? 'Passwords do not match.' : undefined} + /> {error && (

{error}

)} diff --git a/frontend/src/pages/bellcloud/users/UserForm.jsx b/frontend/src/pages/bellcloud/users/UserForm.jsx index d8ea9b4..27299fa 100644 --- a/frontend/src/pages/bellcloud/users/UserForm.jsx +++ b/frontend/src/pages/bellcloud/users/UserForm.jsx @@ -319,6 +319,7 @@ export default function UserForm() { quickSettingsPIN: '', password: '', }) + const [confirmPassword, setConfirmPassword] = useState('') const [uid, setUid] = useState('') const [loading, setLoading] = useState(false) const [saving, setSaving] = useState(false) @@ -356,6 +357,10 @@ export default function UserForm() { const handleSubmit = async (e) => { e.preventDefault() setError('') + if (!isEdit && form.password !== confirmPassword) { + setError('Passwords do not match.') + return + } setSaving(true) try { if (isEdit) { @@ -437,16 +442,28 @@ export default function UserForm() { /> {!isEdit && ( - +
+ + setConfirmPassword(e.target.value)} + required + placeholder="Re-enter password" + error={confirmPassword && form.password !== confirmPassword ? 'Passwords do not match.' : undefined} + /> +
)}