From 75735707ccbb758b6f9b19908aa8df133df2fbd8 Mon Sep 17 00:00:00 2001 From: Priya Bihani Date: Thu, 29 Apr 2021 16:16:13 +0530 Subject: [PATCH 1/3] Update AccountProfilePage.js --- client/views/account/AccountProfilePage.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/views/account/AccountProfilePage.js b/client/views/account/AccountProfilePage.js index ffc211ca7406a..5fbb56827a0ad 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; @@ -117,13 +118,16 @@ const AccountProfilePage = () => { const updateAvatar = useUpdateAvatar(avatar, user._id); const onSave = useCallback(async () => { + // eslint-disable-next-line no-unused-vars const save = async (typedPassword) => { try { await saveFn( { ...(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 +161,7 @@ const AccountProfilePage = () => { canChangeUsername, email, password, + confirmationPassword, realname, statusText, username, From bf51e8c49bbbc4bdbcdd97a1339ed9842d2df71d Mon Sep 17 00:00:00 2001 From: Priya Bihani Date: Thu, 29 Apr 2021 16:19:57 +0530 Subject: [PATCH 2/3] Update AccountProfilePage.js --- client/views/account/AccountProfilePage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/views/account/AccountProfilePage.js b/client/views/account/AccountProfilePage.js index 5fbb56827a0ad..1caf72e642a98 100644 --- a/client/views/account/AccountProfilePage.js +++ b/client/views/account/AccountProfilePage.js @@ -118,7 +118,6 @@ const AccountProfilePage = () => { const updateAvatar = useUpdateAvatar(avatar, user._id); const onSave = useCallback(async () => { - // eslint-disable-next-line no-unused-vars const save = async (typedPassword) => { try { await saveFn( From 3dfccb3bbadacca20c700ff5f759e9602748f04d Mon Sep 17 00:00:00 2001 From: Priya Bihani Date: Mon, 3 May 2021 12:45:03 +0530 Subject: [PATCH 3/3] Update AccountProfileForm.js --- client/views/account/AccountProfileForm.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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, ]);