优化 密码校验策略增加非法字符限制
This commit is contained in:
parent
aa5d5abdf5
commit
8036aa44a3
@ -63,7 +63,7 @@ import { to } from 'await-to-js';
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const registerForm = ref<RegisterForm>({
|
const registerForm = ref<RegisterForm>({
|
||||||
tenantId: '',
|
tenantId: 1,
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
@ -91,7 +91,8 @@ const registerRules: ElFormRules = {
|
|||||||
],
|
],
|
||||||
password: [
|
password: [
|
||||||
{ required: true, trigger: 'blur', message: '请输入您的密码' },
|
{ required: true, trigger: 'blur', message: '请输入您的密码' },
|
||||||
{ min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' }
|
{ min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' },
|
||||||
|
{ pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
|
||||||
],
|
],
|
||||||
confirmPassword: [
|
confirmPassword: [
|
||||||
{ required: true, trigger: 'blur', message: '请再次输入您的密码' },
|
{ required: true, trigger: 'blur', message: '请再次输入您的密码' },
|
||||||
|
@ -425,7 +425,8 @@ const initData: PageData<UserForm, UserQuery> = {
|
|||||||
max: 20,
|
max: 20,
|
||||||
message: '用户密码长度必须介于 5 和 20 之间',
|
message: '用户密码长度必须介于 5 和 20 之间',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
},
|
||||||
|
{ pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
|
||||||
],
|
],
|
||||||
email: [
|
email: [
|
||||||
{
|
{
|
||||||
@ -539,7 +540,12 @@ const handleResetPwd = async (row: UserVO) => {
|
|||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
closeOnClickModal: false,
|
closeOnClickModal: false,
|
||||||
inputPattern: /^.{5,20}$/,
|
inputPattern: /^.{5,20}$/,
|
||||||
inputErrorMessage: '用户密码长度必须介于 5 和 20 之间'
|
inputErrorMessage: '用户密码长度必须介于 5 和 20 之间',
|
||||||
|
inputValidator: (value) => {
|
||||||
|
if (/<|>|"|'|\||\\/.test(value)) {
|
||||||
|
return "不能包含非法字符:< > \" ' \\\ |"
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (!err && res) {
|
if (!err && res) {
|
||||||
|
@ -44,7 +44,8 @@ const rules = ref({
|
|||||||
max: 20,
|
max: 20,
|
||||||
message: '长度在 6 到 20 个字符',
|
message: '长度在 6 到 20 个字符',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
},
|
||||||
|
{ pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
|
||||||
],
|
],
|
||||||
confirmPassword: [
|
confirmPassword: [
|
||||||
{ required: true, message: '确认密码不能为空', trigger: 'blur' },
|
{ required: true, message: '确认密码不能为空', trigger: 'blur' },
|
||||||
|
Loading…
Reference in New Issue
Block a user