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
228c48b3
Commit
228c48b3
authored
Jun 23, 2022
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增云平台验证默认密码Container
parent
dae8f140
Pipeline
#53775
waiting for manual action with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
196 additions
and
0 deletions
+196
-0
index.js
src/components/Container/ValidDefaultPWD/index.js
+137
-0
index.less
src/components/Container/ValidDefaultPWD/index.less
+57
-0
index.js
src/components/Container/index.js
+2
-0
No files found.
src/components/Container/ValidDefaultPWD/index.js
0 → 100644
View file @
228c48b3
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
Modal
,
message
,
Form
,
Input
}
from
'antd'
;
import
{
ExclamationCircleFilled
}
from
'@ant-design/icons'
;
import
{
connect
}
from
'react-redux'
;
import
globalHeader
from
'@wisdom-utils/components/lib/AppLayout/locales/zh-CN/globalHeader'
;
import
{
appService
}
from
'@/api'
;
import
styles
from
'./index.less'
;
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
6
},
sm
:
{
span
:
6
},
},
};
/**
* 云平台上判断是否是默认密码
* 如果是默认密码,强制要求修改密码
*/
const
ValidContainer
=
props
=>
{
const
[
needChangePassword
,
setNeedChangePassword
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
useEffect
(()
=>
{
console
.
log
(
'验证是否默认密码'
)
if
(
window
.
location
.
origin
.
replace
(
/^
(
http|https
)
:
\/\/
/
,
''
)
!==
'panda-water.cn'
)
return
;
const
{
global
}
=
props
;
const
tk
=
global
.
token
;
if
(
tk
)
{
appService
.
validDefaultPWD
({
ignoreSite
:
true
,
token
:
tk
}).
then
(
res
=>
{
setNeedChangePassword
(
res
);
}).
catch
(
err
=>
{
})
}
},
[]);
const
handleOK
=
(
e
)
=>
{
e
.
stopPropagation
();
form
.
validateFields
()
.
then
((
res
)
=>
{
console
.
log
(
res
)
const
params
=
{
password
:
'panda666'
,
newpassword
:
res
.
newPwd
,
token
:
window
.
globalConfig
.
token
,
}
appService
.
changePassword
(
params
)
.
then
((
res
)
=>
{
if
(
res
.
success
)
{
message
.
success
(
globalHeader
[
'component.account.password.update.success'
]);
setTimeout
(()
=>
{
setNeedChangePassword
(
false
);
},
300
);
}
else
{
message
.
error
(
globalHeader
[
'component.account.oldpassword.errorMessage'
]);
}
})
.
catch
((
error
)
=>
{
message
.
error
(
globalHeader
[
'component.account.password.update.fail'
]);
});
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
});
}
return
(
<>
{
props
.
children
}
<
Modal
title
=
"修改密码"
centered
width
=
"362px"
visible
=
{
needChangePassword
}
wrapClassName
=
{
styles
.
updatePassword
}
cancelText
=
"取消"
okText
=
"确定"
onOk
=
{
handleOK
}
onCancel
=
{
event
=>
message
.
info
(
'用户首次登录之前必须修改密码'
)}
// zIndex={2000}
>
<
div
className
=
{
styles
[
'info-label'
]}
>
<
ExclamationCircleFilled
style
=
{{
color
:
'#FCAC0F'
,
fontSize
:
'16px'
}}
/
>
<
span
>
用户首次登录之前必须修改密码
<
/span
>
<
/div
>
<
Form
labelAlign
=
"left"
{...
formItemLayout
}
form
=
{
form
}
>
<
Form
.
Item
name
=
"newPwd"
label
=
"新密码"
rules
=
{[
{
required
:
true
,
message
:
'请输入新密码'
,
},
{
pattern
:
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
a-zA-Z0-9!@#$%^&*_
]{8,16}
$/
,
message
:
'密码字符长度为8-16个字符'
,
},
]}
hasFeedback
>
<
Input
.
Password
/>
<
/Form.Item
>
<
Form
.
Item
name
=
"confirmPwd"
label
=
"确认密码"
dependencies
=
{[
'newPwd'
]}
hasFeedback
rules
=
{[
{
required
:
true
,
message
:
'请输入确认密码'
,
},
({
getFieldValue
})
=>
({
validator
(
rule
,
value
)
{
if
(
!
value
||
getFieldValue
(
'newPwd'
)
===
value
)
{
return
Promise
.
resolve
();
}
return
Promise
.
reject
(
'确认密码与新密码输入不一致'
);
},
}),
]}
>
<
Input
.
Password
/>
<
/Form.Item
>
<
/Form
>
<
/Modal
>
<
/
>
);
};
const
mapStateToProps
=
state
=>
({
global
:
state
.
getIn
([
'global'
,
'globalConfig'
]),
});
export
default
connect
(
mapStateToProps
,
null
,
)(
ValidContainer
);
src/components/Container/ValidDefaultPWD/index.less
0 → 100644
View file @
228c48b3
@import '~~antd/es/style/variable.less';
.updatePassword {
:global {
.anticon {
vertical-align: 0.125em;
}
.@{ant-prefix}-modal-content {
border-radius: 10px;
}
.@{ant-prefix}-modal-header {
padding: 16px 24px 0;
border-bottom: none;
border-radius: 10px 10px 0 0 ;
margin-bottom: 10px;
.@{ant-prefix}-modal-title {
font-size: 16px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #071121;
opacity: 0.85;
}
}
.@{ant-prefix}-modal-body {
padding: 0 24px;
.@{ant-prefix}-form-item {
margin-bottom: 15px;
&:last-of-type {
margin-bottom: 0;
}
}
}
.@{ant-prefix}-modal-footer {
border-top: none;
padding: 13px 24px;
}
.@{ant-prefix}-modal-close {
display: none;
}
}
.info-label {
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: 400;
color: #071121;
opacity: 0.75;
margin-bottom: 20px;
:global {
.anticon {
vertical-align: 0.125em;
margin-right: 5px;
}
}
}
}
\ No newline at end of file
src/components/Container/index.js
View file @
228c48b3
import
React
from
'react'
;
import
{
HandlerMap
}
from
'@wisdom-utils/components'
;
import
ValidDefaultPWDContainer
from
'./ValidDefaultPWD'
;
const
MaintenanceHost
=
window
.
location
.
origin
;
const
MaintenancePath
=
'civmanage'
;
export
{
ValidDefaultPWDContainer
};
export
default
class
Container
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
...
...
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