diff --git a/js/apps/admin-ui/src/user/user-credentials/ResetPasswordDialog.tsx b/js/apps/admin-ui/src/user/user-credentials/ResetPasswordDialog.tsx index 7ed88600c7..30fb1ab9b4 100644 --- a/js/apps/admin-ui/src/user/user-credentials/ResetPasswordDialog.tsx +++ b/js/apps/admin-ui/src/user/user-credentials/ResetPasswordDialog.tsx @@ -52,6 +52,8 @@ export const ResetPasswordDialog = ({ formState: { isValid, errors }, watch, handleSubmit, + clearErrors, + setError, } = useForm({ defaultValues: credFormDefaultValues, mode: "onChange", @@ -59,6 +61,7 @@ export const ResetPasswordDialog = ({ const [confirm, toggle] = useToggle(true); const password = watch("password", ""); + const passwordConfirmation = watch("passwordConfirmation", ""); const { addAlert, addError } = useAlerts(); @@ -121,6 +124,7 @@ export const ResetPasswordDialog = ({ onClose(); }; + const { onChange, ...rest } = register("password", { required: true }); return ( <> @@ -157,7 +161,17 @@ export const ResetPasswordDialog = ({ { + onChange(e); + if (passwordConfirmation !== e.currentTarget.value) { + setError("passwordConfirmation", { + message: t("confirmPasswordDoesNotMatch").toString(), + }); + } else { + clearErrors("passwordConfirmation"); + } + }} + {...rest} />