修改密码增加强度校验
This commit is contained in:
parent
457d1cf846
commit
4cdc151111
|
|
@ -21,6 +21,16 @@ import { updateUserPwd } from "@/api/system/user";
|
|||
|
||||
export default {
|
||||
data() {
|
||||
const passwordRegex = (rule, value, callback) => {
|
||||
const reg = /^((?=.*[A-Za-z])(?=.*\d)|(?=.*[A-Za-z])(?=.*[!@#$%^&*()_+\-\=])|(?=.*\d)(?=.*[!@#$%^&*()_+\-\=]))[A-Za-z\d!@#$%^&*()_+\-\=]{8,20}$/
|
||||
if (value.length < 8 || value.length > 20) {
|
||||
callback(new Error("密码长度在 8 到 20 个字符"));
|
||||
} else if (!reg.test(value)) {
|
||||
callback(new Error("密码须包含数字、字母、特殊符号中的两种以上"));
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const equalToPassword = (rule, value, callback) => {
|
||||
if (this.user.newPassword !== value) {
|
||||
callback(new Error("两次输入的密码不一致"));
|
||||
|
|
@ -41,7 +51,7 @@ export default {
|
|||
],
|
||||
newPassword: [
|
||||
{ required: true, message: "新密码不能为空", trigger: "blur" },
|
||||
{ min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" }
|
||||
{ required: true, validator: passwordRegex, trigger: "blur" }
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, message: "确认密码不能为空", trigger: "blur" },
|
||||
|
|
|
|||
Loading…
Reference in New Issue