Fix changing email & password

Closes #1223

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-12-22 10:56:57 +01:00
parent 16fa1acf24
commit 275261d600
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
1 changed files with 19 additions and 23 deletions

View File

@ -74,17 +74,13 @@
v-model="passwordForEmailChange" v-model="passwordForEmailChange"
/> />
</o-field> </o-field>
<o-button <o-button class="mt-2" variant="primary" nativeType="submit">
class="mt-2"
variant="primary"
:disabled="!(emailForm && emailForm.checkValidity())"
>
{{ t("Change my email") }} {{ t("Change my email") }}
</o-button> </o-button>
</form> </form>
<h2 class="mt-2">{{ t("Password") }}</h2> <h2 class="mt-2">{{ t("Password") }}</h2>
<o-notification <o-notification
v-if="!canChangePassword" v-if="!canChangePassword && loggedUser.provider"
variant="warning" variant="warning"
:closable="false" :closable="false"
> >
@ -134,11 +130,7 @@
v-model="newPassword" v-model="newPassword"
/> />
</o-field> </o-field>
<o-button <o-button class="mt-2" variant="primary" nativeType="submit">
class="mt-2"
variant="primary"
:disabled="!(passwordForm && passwordForm.checkValidity())"
>
{{ t("Change my password") }} {{ t("Change my password") }}
</o-button> </o-button>
</form> </form>
@ -258,8 +250,8 @@ useHead({
title: computed(() => t("General settings")), title: computed(() => t("General settings")),
}); });
const passwordForm = ref<HTMLElement>(); const passwordForm = ref<HTMLFormElement>();
const emailForm = ref<HTMLElement>(); const emailForm = ref<HTMLFormElement>();
const passwordForEmailChange = ref(""); const passwordForEmailChange = ref("");
const newEmail = ref(""); const newEmail = ref("");
@ -294,12 +286,14 @@ changeEmailMutationError((err) => {
}); });
const resetEmailAction = async (): Promise<void> => { const resetEmailAction = async (): Promise<void> => {
changeEmailErrors.value = []; if (emailForm.value?.reportValidity()) {
changeEmailErrors.value = [];
changeEmailMutation({ changeEmailMutation({
email: newEmail.value, email: newEmail.value,
password: passwordForEmailChange.value, password: passwordForEmailChange.value,
}); });
}
}; };
const { const {
@ -319,12 +313,14 @@ onChangePasswordMutationError((err) => {
}); });
const resetPasswordAction = async (): Promise<void> => { const resetPasswordAction = async (): Promise<void> => {
changePasswordErrors.value = []; if (passwordForm.value?.reportValidity()) {
changePasswordErrors.value = [];
changePasswordMutation({ changePasswordMutation({
oldPassword: oldPassword.value, oldPassword: oldPassword.value,
newPassword: newPassword.value, newPassword: newPassword.value,
}); });
}
}; };
const openDeleteAccountModal = (): void => { const openDeleteAccountModal = (): void => {