Commit e2ee9bcc authored by 崔佳豪's avatar 崔佳豪

fix: 添加密码校验规则

parent 9b11b633
Pipeline #53990 passed with stages
......@@ -16,6 +16,8 @@ const formItemLayout = {
* 云平台上判断是否是默认密码
* 如果是默认密码,强制要求修改密码
*/
let info = '666';
let infoPre = 'panda';
const ValidContainer = props => {
const [needChangePassword, setNeedChangePassword] = useState(false);
const [form] = Form.useForm();
......@@ -28,7 +30,11 @@ const ValidContainer = props => {
ignoreSite: true,
token: tk
}).then(res => {
setNeedChangePassword(res);
if(res.code === 0) {
const { data } = res;
setNeedChangePassword(data.valid);
info = data.info;
}
}).catch(err => {
})
}
......@@ -39,29 +45,28 @@ const ValidContainer = props => {
form
.validateFields()
.then((res) => {
console.log(res)
const params = {
password: 'panda666',
password: `${infoPre}${info}`, // 拼接默认密码
newpassword: res.newPwd,
token: window.globalConfig.token,
ignoreSite: true,
}
appService
.changePassword(params)
.then((res) => {
if (res.success) {
message.success(globalHeader['component.account.password.update.success']);
setTimeout(() => {
// setNeedChangePassword(false);
props.logout();
}, 300);
} else {
message.error(globalHeader['component.account.oldpassword.errorMessage']);
}
})
.catch((error) => {
message.error(globalHeader['component.account.password.update.fail']);
});
.changePassword(params)
.then((res) => {
if (res.success) {
message.success(globalHeader['component.account.password.update.success']);
setTimeout(() => {
// setNeedChangePassword(false);
props.logout();
}, 300);
} else {
message.error(globalHeader['component.account.oldpassword.errorMessage']);
}
})
.catch((error) => {
message.error(globalHeader['component.account.password.update.fail']);
});
}).catch((error) => {
console.log(error)
});
......@@ -98,6 +103,13 @@ const ValidContainer = props => {
pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9!@#$%^&*_]{8,16}$/,
message: '密码字符长度为8-16个字符',
},
({ getFieldValue }) => ({
validator(rule, value) {
if(value === `${infoPre}${props?.global?.userInfo?.loginName ?? info}` || value === 'panda666')
return Promise.reject('密码规则不允许');
return Promise.resolve();
},
})
]}
hasFeedback
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment