Skip to content

Commit 43a328d

Browse files
committed
fix(auth): update password hashing logic and improve confirmation validation
1 parent 6ce8507 commit 43a328d

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

dashboard/src/layouts/full/vertical-header/VerticalHeader.vue

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ const passwordRules = computed(() => [
9191
(v: string) => v.length >= 8 || t('core.header.accountDialog.validation.passwordMinLength')
9292
]);
9393
const confirmPasswordRules = computed(() => [
94-
(v: string) => !!newPassword.value || t('core.header.accountDialog.validation.passwordRequired'),
95-
(v: string) => v === newPassword.value || t('core.header.accountDialog.validation.passwordMatch')
94+
(v: string) => !newPassword.value || !!v || t('core.header.accountDialog.validation.passwordRequired'),
95+
(v: string) => !newPassword.value || v === newPassword.value || t('core.header.accountDialog.validation.passwordMatch')
9696
]);
9797
const usernameRules = computed(() => [
9898
(v: string) => !v || v.length >= 3 || t('core.header.accountDialog.validation.usernameMinLength')
@@ -101,7 +101,7 @@ const usernameRules = computed(() => [
101101
// 显示密码相关
102102
const showPassword = ref(false);
103103
const showNewPassword = ref(false);
104-
const showConfirmPassword = ref(false);;
104+
const showConfirmPassword = ref(false);
105105
106106
// 账户修改状态
107107
const accountEditStatus = ref({
@@ -175,21 +175,14 @@ function accountEdit() {
175175
accountEditStatus.value.error = false;
176176
accountEditStatus.value.success = false;
177177
178-
// md5加密
179-
// @ts-ignore
180-
if (password.value != '') {
181-
password.value = md5(password.value);
182-
}
183-
if (newPassword.value != '') {
184-
newPassword.value = md5(newPassword.value);
185-
}
186-
if (confirmPassword.value != '') {
187-
confirmPassword.value = md5(confirmPassword.value);
188-
}
178+
const passwordHash = password.value ? md5(password.value) : '';
179+
const newPasswordHash = newPassword.value ? md5(newPassword.value) : '';
180+
const confirmPasswordHash = confirmPassword.value ? md5(confirmPassword.value) : '';
181+
189182
axios.post('/api/auth/account/edit', {
190-
password: password.value,
191-
new_password: newPassword.value,
192-
confirm_password: confirmPassword.value,
183+
password: passwordHash,
184+
new_password: newPasswordHash,
185+
confirm_password: confirmPasswordHash,
193186
new_username: newUsername.value ? newUsername.value : username
194187
})
195188
.then((res) => {

0 commit comments

Comments
 (0)