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

fix: 添加密码校验规则

parent 9b11b633
Pipeline #53990 passed with stages
...@@ -16,6 +16,8 @@ const formItemLayout = { ...@@ -16,6 +16,8 @@ const formItemLayout = {
* 云平台上判断是否是默认密码 * 云平台上判断是否是默认密码
* 如果是默认密码,强制要求修改密码 * 如果是默认密码,强制要求修改密码
*/ */
let info = '666';
let infoPre = 'panda';
const ValidContainer = props => { const ValidContainer = props => {
const [needChangePassword, setNeedChangePassword] = useState(false); const [needChangePassword, setNeedChangePassword] = useState(false);
const [form] = Form.useForm(); const [form] = Form.useForm();
...@@ -28,7 +30,11 @@ const ValidContainer = props => { ...@@ -28,7 +30,11 @@ const ValidContainer = props => {
ignoreSite: true, ignoreSite: true,
token: tk token: tk
}).then(res => { }).then(res => {
setNeedChangePassword(res); if(res.code === 0) {
const { data } = res;
setNeedChangePassword(data.valid);
info = data.info;
}
}).catch(err => { }).catch(err => {
}) })
} }
...@@ -39,9 +45,8 @@ const ValidContainer = props => { ...@@ -39,9 +45,8 @@ const ValidContainer = props => {
form form
.validateFields() .validateFields()
.then((res) => { .then((res) => {
console.log(res)
const params = { const params = {
password: 'panda666', password: `${infoPre}${info}`, // 拼接默认密码
newpassword: res.newPwd, newpassword: res.newPwd,
token: window.globalConfig.token, token: window.globalConfig.token,
ignoreSite: true, ignoreSite: true,
...@@ -98,6 +103,13 @@ const ValidContainer = props => { ...@@ -98,6 +103,13 @@ const ValidContainer = props => {
pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9!@#$%^&*_]{8,16}$/, pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9!@#$%^&*_]{8,16}$/,
message: '密码字符长度为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 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