From 275261d60032589c152e5140aae846f79618924d Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 22 Dec 2022 10:56:57 +0100 Subject: [PATCH] Fix changing email & password Closes #1223 Signed-off-by: Thomas Citharel --- js/src/views/Settings/AccountSettings.vue | 42 ++++++++++------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/js/src/views/Settings/AccountSettings.vue b/js/src/views/Settings/AccountSettings.vue index eafb64894..ef9b32085 100644 --- a/js/src/views/Settings/AccountSettings.vue +++ b/js/src/views/Settings/AccountSettings.vue @@ -74,17 +74,13 @@ v-model="passwordForEmailChange" /> - + {{ t("Change my email") }}

{{ t("Password") }}

@@ -134,11 +130,7 @@ v-model="newPassword" /> - + {{ t("Change my password") }} @@ -258,8 +250,8 @@ useHead({ title: computed(() => t("General settings")), }); -const passwordForm = ref(); -const emailForm = ref(); +const passwordForm = ref(); +const emailForm = ref(); const passwordForEmailChange = ref(""); const newEmail = ref(""); @@ -294,12 +286,14 @@ changeEmailMutationError((err) => { }); const resetEmailAction = async (): Promise => { - changeEmailErrors.value = []; + if (emailForm.value?.reportValidity()) { + changeEmailErrors.value = []; - changeEmailMutation({ - email: newEmail.value, - password: passwordForEmailChange.value, - }); + changeEmailMutation({ + email: newEmail.value, + password: passwordForEmailChange.value, + }); + } }; const { @@ -319,12 +313,14 @@ onChangePasswordMutationError((err) => { }); const resetPasswordAction = async (): Promise => { - changePasswordErrors.value = []; + if (passwordForm.value?.reportValidity()) { + changePasswordErrors.value = []; - changePasswordMutation({ - oldPassword: oldPassword.value, - newPassword: newPassword.value, - }); + changePasswordMutation({ + oldPassword: oldPassword.value, + newPassword: newPassword.value, + }); + } }; const openDeleteAccountModal = (): void => {