forked from integrated_whb/integrated_whb_vue
feat(layout): 增强密码安全性验证
- 添加新的密码验证规则,要求密码至少为8位,包含大小写字母、数字和特殊符号 - 修改密码确认字段的验证逻辑,提高用户体验 - 调整密码输入框的样式,增加密码强度提示dev
parent
3851711c06
commit
c28fec0270
|
@ -71,6 +71,21 @@ const emits = defineEmits(["update:visible", "update:form", "get-data"]);
|
||||||
const { visible, form } = useVModels(props, emits);
|
const { visible, form } = useVModels(props, emits);
|
||||||
const formRef = ref(null);
|
const formRef = ref(null);
|
||||||
const validatePass = (rule, value, callback) => {
|
const validatePass = (rule, value, callback) => {
|
||||||
|
if (value) {
|
||||||
|
const reg1 =
|
||||||
|
/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*.])[\da-zA-Z~!@#$%^&*.]{8,}$/;
|
||||||
|
if (!reg1.test(value)) {
|
||||||
|
callback(
|
||||||
|
new Error("密码必须是8位以上、必须包含大小写字母、数字、特殊符号")
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const validatePass2 = (rule, value, callback) => {
|
||||||
if (form.value.newpwd && !value) {
|
if (form.value.newpwd && !value) {
|
||||||
callback(new Error("请再次输入新密码"));
|
callback(new Error("请再次输入新密码"));
|
||||||
} else if (form.value.newpwd && value && value !== form.value.newpwd) {
|
} else if (form.value.newpwd && value && value !== form.value.newpwd) {
|
||||||
|
@ -102,9 +117,11 @@ const rules = {
|
||||||
],
|
],
|
||||||
newpwd: [
|
newpwd: [
|
||||||
{ required: false, message: "请输入新密码", trigger: "blur" },
|
{ required: false, message: "请输入新密码", trigger: "blur" },
|
||||||
{ min: 6, max: 18, message: "密码长度为6-18位", trigger: "blur" },
|
{ required: true, validator: validatePass, trigger: "blur" },
|
||||||
|
],
|
||||||
|
newpassword1: [
|
||||||
|
{ required: false, validator: validatePass2, trigger: "blur" },
|
||||||
],
|
],
|
||||||
newpassword1: [{ required: false, validator: validatePass, trigger: "blur" }],
|
|
||||||
};
|
};
|
||||||
const fnSubmit = debounce(
|
const fnSubmit = debounce(
|
||||||
1000,
|
1000,
|
||||||
|
|
Loading…
Reference in New Issue