diff --git a/client/views/account/AccountProfileForm.js b/client/views/account/AccountProfileForm.js index 87d4dd2df55bf..c0f972799f017 100644 --- a/client/views/account/AccountProfileForm.js +++ b/client/views/account/AccountProfileForm.js @@ -88,13 +88,16 @@ function AccountProfileForm({ values, handlers, user, settings, onSaveStateChang } }, [dispatchToastMessage, email, previousEmail, sendConfirmationEmail, t]); - const passwordError = useMemo( - () => - !password || !confirmationPassword || password === confirmationPassword - ? undefined - : t('Passwords_do_not_match'), - [t, password, confirmationPassword], - ); + const passwordError = useMemo(() => { + if (password && !confirmationPassword) { + return t('Confirm to change password'); + } + if (password !== confirmationPassword) { + return t('Passwords_do_not_match'); + } + return undefined; + }, [t, password, confirmationPassword]); + const emailError = useMemo(() => (isEmail(email) ? undefined : 'error-invalid-email-address'), [ email, ]); diff --git a/client/views/account/AccountProfilePage.js b/client/views/account/AccountProfilePage.js index ffc211ca7406a..1caf72e642a98 100644 --- a/client/views/account/AccountProfilePage.js +++ b/client/views/account/AccountProfilePage.js @@ -108,6 +108,7 @@ const AccountProfilePage = () => { statusText, statusType, customFields, + confirmationPassword, bio, nickname, } = values; @@ -123,7 +124,9 @@ const AccountProfilePage = () => { { ...(allowRealNameChange && { realname }), ...(allowEmailChange && getUserEmailAddress(user) !== email && { email }), - ...(allowPasswordChange && { newPassword: password }), + ...(allowPasswordChange && { + newPassword: password === confirmationPassword ? password : '', + }), ...(canChangeUsername && { username }), ...(allowUserStatusMessageChange && { statusText }), ...(typedPassword && { typedPassword: SHA256(typedPassword) }), @@ -157,6 +160,7 @@ const AccountProfilePage = () => { canChangeUsername, email, password, + confirmationPassword, realname, statusText, username,