Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivWeb
Commits
e2ee9bcc
Commit
e2ee9bcc
authored
Jun 27, 2022
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 添加密码校验规则
parent
9b11b633
Pipeline
#53990
passed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
index.js
src/components/Container/ValidDefaultPWD/index.js
+30
-18
No files found.
src/components/Container/ValidDefaultPWD/index.js
View file @
e2ee9bcc
...
...
@@ -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
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment