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
8252d329
Commit
8252d329
authored
Sep 23, 2022
by
杨思琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 弱口令检测
parent
7b6f465f
Pipeline
#60930
waiting for manual action with stages
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
46 deletions
+52
-46
index.js
src/components/Container/ValidDefaultPWD/index.js
+40
-43
AvatarDropdown.js
...youts/AppLayout/components/GlobalHeader/AvatarDropdown.js
+12
-3
login.js
src/pages/user/login/login.js
+0
-0
render.js
src/render.js
+0
-0
No files found.
src/components/Container/ValidDefaultPWD/index.js
View file @
8252d329
...
...
@@ -16,61 +16,65 @@ const formItemLayout = {
* 云平台上判断是否是默认密码
* 如果是默认密码,强制要求修改密码
*/
let
info
=
'666'
;
let
infoPre
=
'panda'
;
const
ValidContainer
=
props
=>
{
const
[
needChangePassword
,
setNeedChangePassword
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
// eslint-disable-next-line react/no-this-in-sfc
const
password
=
localStorage
.
getItem
(
'password_token'
);
let
rules
=
localStorage
.
getItem
(
'password_pwdRegex'
);
const
rulesTip
=
localStorage
.
getItem
(
'password_pwdRegexTip'
);
let
reg
;
try
{
reg
=
new
RegExp
(
rules
);
}
catch
(
error
)
{
rules
=
''
;
reg
=
new
RegExp
(
rules
);
}
useEffect
(()
=>
{
if
(
window
.
location
.
origin
.
replace
(
/^
(
http|https
)
:
\/\/
/
,
''
)
!==
'panda-water.cn'
)
return
;
//
if (window.location.origin.replace(/^(http|https):\/\//, '') !== 'panda-water.cn') return;
const
{
global
}
=
props
;
const
tk
=
global
.
token
;
// eslint-disable-next-line no-eval
if
(
tk
)
{
appService
.
validDefaultPWD
({
ignoreSite
:
true
,
token
:
tk
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
const
{
data
}
=
res
;
setNeedChangePassword
(
data
.
valid
);
info
=
data
.
info
;
}
}).
catch
(
err
=>
{
})
if
(
rules
!==
''
&&
!
reg
.
test
(
password
))
{
setNeedChangePassword
(
true
);
}
}
},
[]);
const
handleOK
=
(
e
)
=>
{
const
handleOK
=
e
=>
{
e
.
stopPropagation
();
form
.
validateFields
()
.
then
(
(
res
)
=>
{
.
then
(
res
=>
{
const
params
=
{
password
:
`
${
infoPre
}${
info
}
`
,
// 拼接默认密码
newpassword
:
res
.
newPwd
,
token
:
window
.
globalConfig
.
token
,
ignoreSite
:
true
,
}
password
,
// 拼接默认密码
newpassword
:
res
.
newPwd
,
token
:
window
.
globalConfig
.
token
,
ignoreSite
:
true
,
}
;
appService
.
changePassword
(
params
)
.
then
((
res
)
=>
{
// eslint-disable-next-line no-shadow
.
then
(
res
=>
{
if
(
res
.
success
)
{
message
.
success
(
globalHeader
[
'component.account.password.update.success'
]);
setTimeout
(()
=>
{
//
setNeedChangePassword(false);
props
.
logout
();
setNeedChangePassword
(
false
);
//
props.logout();
},
300
);
}
else
{
message
.
error
(
globalHeader
[
'component.account.oldpassword.errorMessage'
]);
}
})
.
catch
(
(
error
)
=>
{
.
catch
(
error
=>
{
message
.
error
(
globalHeader
[
'component.account.password.update.fail'
]);
});
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
}
}
;
return
(
<>
{
props
.
children
}
...
...
@@ -87,8 +91,8 @@ const ValidContainer = props => {
// zIndex={2000}
>
<
div
className
=
{
styles
[
'info-label'
]}
>
<
ExclamationCircleFilled
style
=
{{
color
:
'#FCAC0F'
,
fontSize
:
'16px'
}}
/
>
<
span
>
用户首次登录之前必须修改密码
<
/span
>
<
ExclamationCircleFilled
style
=
{{
color
:
'#FCAC0F'
,
fontSize
:
'16px'
}}
/
>
<
span
>
用户首次登录之前必须修改密码
<
/span
>
<
/div
>
<
Form
labelAlign
=
"left"
{...
formItemLayout
}
form
=
{
form
}
>
<
Form
.
Item
...
...
@@ -100,16 +104,9 @@ const ValidContainer = props => {
message
:
'请输入新密码'
,
},
{
pattern
:
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
a-zA-Z0-9_
]{8,16}
$/
,
message
:
'密码需为8-16个数字、字符和下划线'
,
pattern
:
reg
,
message
:
rulesTip
,
},
({
getFieldValue
})
=>
({
validator
(
rule
,
value
)
{
if
(
value
===
`
${
infoPre
}${
props
?.
global
?.
userInfo
?.
loginName
??
info
}
` || value === 'panda666')
return Promise.reject('密码规则不允许');
return Promise.resolve();
},
})
]}
hasFeedback
>
...
...
@@ -127,13 +124,13 @@ const ValidContainer = props => {
},
({
getFieldValue
})
=>
({
validator
(
rule
,
value
)
{
if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9_]{8,16}$/.test(value))
return Promise.reject('密码需为8-16个数字、字符和下划线');
if (value === `
$
{
infoPre
}
$
{
props
?.
global
?.
userInfo
?.
loginName
??
info
}
` || value === 'panda666')
return Promise.reject('密码规则不允许');
if
(
!
reg
.
test
(
value
))
// eslint-disable-next-line prefer-promise-reject-errors
return
Promise
.
reject
(
rulesTip
);
if
(
!
value
||
getFieldValue
(
'newPwd'
)
===
value
)
{
return
Promise
.
resolve
();
}
// eslint-disable-next-line prefer-promise-reject-errors
return
Promise
.
reject
(
'确认密码与新密码输入不一致'
);
},
}),
...
...
src/layouts/AppLayout/components/GlobalHeader/AvatarDropdown.js
View file @
8252d329
...
...
@@ -25,7 +25,7 @@ const getIOT = () =>
class
AvatarDropdown
extends
React
.
Component
{
/* eslint-disable no-unused-vars */
constructor
(
props
)
{
super
(
props
);
let
{
...
...
@@ -41,7 +41,16 @@ class AvatarDropdown extends React.Component {
popVisible
:
false
,
path
:
null
,
action
:
API
.
UPLOAD_FILE_URL
,
rulesTip
:
localStorage
.
getItem
(
'password_pwdRegexTip'
),
reg
:
''
};
let
rules
=
localStorage
.
getItem
(
'password_pwdRegex'
);
try
{
this
.
state
.
reg
=
new
RegExp
(
rules
);
}
catch
(
error
)
{
rules
=
''
;
this
.
state
.
reg
=
new
RegExp
(
rules
);
}
}
loginout
=
(
event
)
=>
{
// eslint-disable-next-line no-undef
...
...
@@ -424,8 +433,8 @@ class AvatarDropdown extends React.Component {
message
:
'请输入新密码'
,
},
{
pattern
:
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
a-zA-Z0-9!@#$%^&*_
]{8,16}
$/
,
message
:
'密码字符长度为8-16个字符'
,
pattern
:
this
.
state
.
reg
,
message
:
this
.
state
.
rulesTip
,
},
]}
hasFeedback
...
...
src/pages/user/login/login.js
View file @
8252d329
This diff is collapsed.
Click to expand it.
src/render.js
View file @
8252d329
This diff is collapsed.
Click to expand it.
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