From 61fc9739514db0379112c5ba7e9146190967f353 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 11 Feb 2025 12:40:16 +0100 Subject: [PATCH] fix: refs #8554 update password handling based on user identity --- .../Account/Card/AccountDescriptorMenu.vue | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/pages/Account/Card/AccountDescriptorMenu.vue b/src/pages/Account/Card/AccountDescriptorMenu.vue index ccf029e44..9e573b1bd 100644 --- a/src/pages/Account/Card/AccountDescriptorMenu.vue +++ b/src/pages/Account/Card/AccountDescriptorMenu.vue @@ -34,6 +34,12 @@ account.value.hasAccount = hasAccount.value; const entityId = computed(() => +route.params.id); const hasitManagementAccess = ref(); const hasSysadminAccess = ref(); +const isHimself = computed(() => user.value.id === account.value.id); +const url = computed(() => + isHimself.value + ? 'Accounts/change-password' + : `Accounts/${entityId.value}/setPassword` +); async function updateStatusAccount(active) { if (active) { @@ -106,11 +112,8 @@ onMounted(() => { :ask-old-pass="askOldPass" :submit-fn=" async (newPassword, oldPassword) => { - await axios.patch(`Accounts/change-password`, { - userId: entityId, - newPassword, - oldPassword, - }); + const body = isHimself ? { userId: entityId, oldPassword } : {}; + await axios.patch(url, { ...body, newPassword }); } " /> @@ -158,16 +161,10 @@ onMounted(() => { > {{ t('globals.delete') }} - - - {{ t('globals.changePass') }} + + + {{ isHimself ? t('globals.changePass') : t('globals.setPass') }} - {{ t('globals.setPass') }}