consider the situation when reset section is not open. consider the situation when password is not sent to backend

This commit is contained in:
Cindy Chang
2024-08-26 13:53:49 +08:00
parent 97e01c93fd
commit ff8179404b

View File

@@ -234,7 +234,7 @@ export default defineComponent({
}; };
const validatePwdLength = () => { const validatePwdLength = () => {
isPwdLengthValid.value = inputPwd.value.length >= PWD_VALID_LENGTH; isPwdLengthValid.value = !isResetPwdSectionShow.value || inputPwd.value.length >= PWD_VALID_LENGTH;
} }
const onInputDoubleClick = () => { const onInputDoubleClick = () => {
@@ -274,6 +274,8 @@ export default defineComponent({
return; return;
} }
// 要注意的是舊的username跟新的username可以是不同的 // 要注意的是舊的username跟新的username可以是不同的
// 區分有無傳入密碼的情況
if(isResetPwdSectionShow.value) {
await acctMgmtStore.editAccount( await acctMgmtStore.editAccount(
currentViewingUser.value.username, { currentViewingUser.value.username, {
newUsername: inputUserAccount.value, newUsername: inputUserAccount.value,
@@ -281,6 +283,14 @@ export default defineComponent({
name: inputName.value === undefined ? '' : inputName.value, name: inputName.value === undefined ? '' : inputName.value,
is_active: true, is_active: true,
}); });
} else {
await acctMgmtStore.editAccount(
currentViewingUser.value.username, {
newUsername: inputUserAccount.value,
name: inputName.value === undefined ? '' : inputName.value,
is_active: true,
});
}
await toast.success(i18next.t("AcctMgmt.MsgAccountEdited")); await toast.success(i18next.t("AcctMgmt.MsgAccountEdited"));
isEditable.value = false; isEditable.value = false;
break; break;
@@ -327,9 +337,10 @@ export default defineComponent({
[inputPwd, inputUserAccount, inputName], [inputPwd, inputUserAccount, inputName],
([newPwd, newAccount, newName]) => { ([newPwd, newAccount, newName]) => {
// 只要[確認密碼]或[密碼]欄位有更動且所有欄位都不是空的confirm 按鈕就可點選 // 只要[確認密碼]或[密碼]欄位有更動且所有欄位都不是空的confirm 按鈕就可點選
if (newPwd.length > 0 && newAccount.length > 0 && newName.length > 0) { if(newAccount.length > 0 && newName.length > 0) {
isConfirmDisabled.value = false; isConfirmDisabled.value = false;
} else { }
if(isResetPwdSectionShow.value && newPwd.length < PWD_VALID_LENGTH) {
isConfirmDisabled.value = true; isConfirmDisabled.value = true;
} }
} }