Commit 228c48b3 authored by 崔佳豪's avatar 崔佳豪

feat: 新增云平台验证默认密码Container

parent dae8f140
Pipeline #53775 waiting for manual action with stages
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);
@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
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);
......
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