Skip to content

Commit 85d304e

Browse files
perf: Password Change Page - Prompt Wording Optimization
1 parent c1dabe5 commit 85d304e

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

frontend/src/components/layout/PwdForm.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ const pwdForm = reactive({
99
new_pwd: '',
1010
confirm_pwd: '',
1111
})
12-
12+
const PWD_REGEX =
13+
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+\-={}|:"<>?`\[\];',./])[A-Za-z\d~!@#$%^&*()_+\-={}|:"<>?`\[\];',./]{8,20}$/
1314
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1415
// @ts-ignore
1516
const validatePass = (rule: any, value: any, callback: any) => {
1617
if (value === '') {
1718
callback(new Error(t('common.please_input', { msg: t('user.upgrade_pwd.new_pwd') })))
1819
} else {
20+
if (!PWD_REGEX.test(value)) {
21+
callback(new Error(t('user.upgrade_pwd.pwd_format_error')))
22+
return
23+
}
1924
if (pwdForm.confirm_pwd !== '') {
2025
if (!pwdRef.value) return
2126
pwdRef.value.validateField('confirm_pwd')
@@ -28,6 +33,8 @@ const validatePass = (rule: any, value: any, callback: any) => {
2833
const validatePass2 = (rule: any, value: any, callback: any) => {
2934
if (value === '') {
3035
callback(new Error(t('common.please_input', { msg: t('user.upgrade_pwd.confirm_pwd') })))
36+
} else if (!PWD_REGEX.test(value)) {
37+
callback(new Error(t('user.upgrade_pwd.pwd_format_error')))
3138
} else if (value !== pwdForm.new_pwd) {
3239
callback(new Error(t('user.upgrade_pwd.two_pwd_not_match')))
3340
} else {

frontend/src/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@
386386
"old_pwd": "Old password",
387387
"new_pwd": "New password",
388388
"confirm_pwd": "Confirm password",
389-
"two_pwd_not_match": "The two passwords do not match"
389+
"two_pwd_not_match": "The two passwords do not match",
390+
"pwd_format_error": "8-20 characters including uppercase, lowercase, number, and special character"
390391
}
391392
},
392393
"workspace": {

frontend/src/i18n/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@
386386
"old_pwd": "旧密码",
387387
"new_pwd": "新密码",
388388
"confirm_pwd": "确认密码",
389-
"two_pwd_not_match": "两次输入的密码不一致"
389+
"two_pwd_not_match": "两次输入的密码不一致",
390+
"pwd_format_error": "8-20位且至少一位大写字母、小写字母、数字、特殊字符"
390391
}
391392
},
392393
"workspace": {

0 commit comments

Comments
 (0)