|
|
@ -17,14 +17,14 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { LockOutlined, UserOutlined } from '@ant-design/icons';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
Typography,
|
|
|
|
Typography,
|
|
|
|
Row,
|
|
|
|
Row,
|
|
|
|
Col,
|
|
|
|
Col,
|
|
|
|
Form,
|
|
|
|
|
|
|
|
Icon,
|
|
|
|
|
|
|
|
Input,
|
|
|
|
Input,
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
|
|
|
|
Form,
|
|
|
|
Checkbox,
|
|
|
|
Checkbox,
|
|
|
|
notification,
|
|
|
|
notification,
|
|
|
|
} from 'antd';
|
|
|
|
} from 'antd';
|
|
|
@ -36,40 +36,6 @@ const { Title } = Typography;
|
|
|
|
const { Text } = Typography;
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
class Login extends React.Component {
|
|
|
|
class Login extends React.Component {
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const config = this.props.context;
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div className="login">
|
|
|
|
|
|
|
|
<div className="background"></div>
|
|
|
|
|
|
|
|
<div className="content">
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
|
|
<Col xs={3} sm={3} md={10}></Col>
|
|
|
|
|
|
|
|
<Col xs={18} sm={18} md={4}>
|
|
|
|
|
|
|
|
<Row style={{ marginBottom: 20 }}>
|
|
|
|
|
|
|
|
<Col style={{ textAlign: 'center' }}>
|
|
|
|
|
|
|
|
<img
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
marginTop: 36,
|
|
|
|
|
|
|
|
height: 60,
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
src={config.theme.logo}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<Title level={2}>Login</Title>
|
|
|
|
|
|
|
|
<WrappedNormalLoginForm />
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
|
|
<Col span={4} offset={10}></Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NormalLoginForm extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
this.state = {
|
|
|
@ -78,18 +44,10 @@ class NormalLoginForm extends React.Component {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleSubmit = e => {
|
|
|
|
handleSubmit = values => {
|
|
|
|
const thisForm = this;
|
|
|
|
this.setState({
|
|
|
|
const config = this.props.context;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
this.props.form.validateFields((err, values) => {
|
|
|
|
|
|
|
|
thisForm.setState({
|
|
|
|
|
|
|
|
inValid: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!err) {
|
|
|
|
|
|
|
|
thisForm.setState({
|
|
|
|
|
|
|
|
loading: true,
|
|
|
|
loading: true,
|
|
|
|
|
|
|
|
inValid: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const parameters = {
|
|
|
|
const parameters = {
|
|
|
|
username: values.username,
|
|
|
|
username: values.username,
|
|
|
@ -102,7 +60,7 @@ class NormalLoginForm extends React.Component {
|
|
|
|
.join('&');
|
|
|
|
.join('&');
|
|
|
|
|
|
|
|
|
|
|
|
axios
|
|
|
|
axios
|
|
|
|
.post(window.location.origin + config.serverConfig.loginUri, request)
|
|
|
|
.post(window.location.origin + '/store-ui-request-handler/login', request)
|
|
|
|
.then(res => {
|
|
|
|
.then(res => {
|
|
|
|
if (res.status === 200) {
|
|
|
|
if (res.status === 200) {
|
|
|
|
let redirectUrl = window.location.origin + '/store';
|
|
|
|
let redirectUrl = window.location.origin + '/store';
|
|
|
@ -111,14 +69,13 @@ class NormalLoginForm extends React.Component {
|
|
|
|
redirectUrl = searchParams.get('redirect');
|
|
|
|
redirectUrl = searchParams.get('redirect');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window.location = redirectUrl;
|
|
|
|
window.location = redirectUrl;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new Error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(function(error) {
|
|
|
|
.catch(error => {
|
|
|
|
if (
|
|
|
|
if (error.hasOwnProperty('response') && error.response.status === 401) {
|
|
|
|
error.hasOwnProperty('response') &&
|
|
|
|
this.setState({
|
|
|
|
error.response.status === 401
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
thisForm.setState({
|
|
|
|
|
|
|
|
loading: false,
|
|
|
|
loading: false,
|
|
|
|
inValid: true,
|
|
|
|
inValid: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -128,81 +85,101 @@ class NormalLoginForm extends React.Component {
|
|
|
|
duration: 10,
|
|
|
|
duration: 10,
|
|
|
|
description: '',
|
|
|
|
description: '',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
thisForm.setState({
|
|
|
|
this.setState({
|
|
|
|
loading: false,
|
|
|
|
loading: false,
|
|
|
|
inValid: false,
|
|
|
|
inValid: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
const { getFieldDecorator } = this.props.form;
|
|
|
|
const config = this.props.context;
|
|
|
|
let errorMsg = '';
|
|
|
|
|
|
|
|
if (this.state.inValid) {
|
|
|
|
|
|
|
|
errorMsg = <Text type="danger">Invalid Login Details</Text>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let loading = '';
|
|
|
|
|
|
|
|
if (this.state.loading) {
|
|
|
|
|
|
|
|
loading = <Text type="secondary">Loading..</Text>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Form onSubmit={this.handleSubmit} className="login-form">
|
|
|
|
<div className="login">
|
|
|
|
<Form.Item>
|
|
|
|
<div className="background"></div>
|
|
|
|
{getFieldDecorator('username', {
|
|
|
|
<div className="content">
|
|
|
|
rules: [{ required: true, message: 'Please input your username!' }],
|
|
|
|
<Row>
|
|
|
|
})(
|
|
|
|
<Col xs={3} sm={3} md={10}></Col>
|
|
|
|
|
|
|
|
<Col xs={18} sm={18} md={4}>
|
|
|
|
|
|
|
|
<Row style={{ marginBottom: 20 }}>
|
|
|
|
|
|
|
|
<Col
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
display: 'block',
|
|
|
|
|
|
|
|
marginLeft: 'auto',
|
|
|
|
|
|
|
|
marginRight: 'auto',
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<img
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
marginTop: 36,
|
|
|
|
|
|
|
|
height: 60,
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
src={config.theme.logo}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<Title level={2}>Login</Title>
|
|
|
|
|
|
|
|
<Form
|
|
|
|
|
|
|
|
initialValues={{ remember: true }}
|
|
|
|
|
|
|
|
onFinish={this.handleSubmit}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
|
|
name="username"
|
|
|
|
|
|
|
|
rules={[
|
|
|
|
|
|
|
|
{ required: true, message: 'Please input your username!' },
|
|
|
|
|
|
|
|
]}
|
|
|
|
|
|
|
|
>
|
|
|
|
<Input
|
|
|
|
<Input
|
|
|
|
name="username"
|
|
|
|
name="username"
|
|
|
|
style={{ height: 32 }}
|
|
|
|
style={{ height: 32 }}
|
|
|
|
prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
|
|
prefix={
|
|
|
|
|
|
|
|
<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }} />
|
|
|
|
|
|
|
|
}
|
|
|
|
placeholder="Username"
|
|
|
|
placeholder="Username"
|
|
|
|
/>,
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
{getFieldDecorator('password', {
|
|
|
|
|
|
|
|
rules: [{ required: true, message: 'Please input your Password!' }],
|
|
|
|
|
|
|
|
})(
|
|
|
|
|
|
|
|
<Input
|
|
|
|
|
|
|
|
name="password"
|
|
|
|
name="password"
|
|
|
|
style={{ height: 32 }}
|
|
|
|
rules={[
|
|
|
|
prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
|
|
{ required: true, message: 'Please input your password!' },
|
|
|
|
type="password"
|
|
|
|
]}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Input.Password
|
|
|
|
|
|
|
|
prefix={
|
|
|
|
|
|
|
|
<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />
|
|
|
|
|
|
|
|
}
|
|
|
|
placeholder="Password"
|
|
|
|
placeholder="Password"
|
|
|
|
/>,
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
{this.state.loading && <Text type="secondary">Loading..</Text>}
|
|
|
|
|
|
|
|
{this.state.inValid && (
|
|
|
|
|
|
|
|
<Text type="danger">Invalid Login Details</Text>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
<a href="">Forgot password</a>
|
|
|
|
|
|
|
|
<Form.Item name="remember" valuePropName="checked">
|
|
|
|
|
|
|
|
<Checkbox>Remember me</Checkbox>
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
{loading}
|
|
|
|
|
|
|
|
{errorMsg}
|
|
|
|
|
|
|
|
<Form.Item>
|
|
|
|
<Form.Item>
|
|
|
|
{getFieldDecorator('remember', {
|
|
|
|
|
|
|
|
valuePropName: 'checked',
|
|
|
|
|
|
|
|
initialValue: true,
|
|
|
|
|
|
|
|
})(<Checkbox>Remember me</Checkbox>)}
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
<a className="login-form-forgot" href="">
|
|
|
|
|
|
|
|
Forgot password
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
loading={this.state.loading}
|
|
|
|
|
|
|
|
block
|
|
|
|
|
|
|
|
type="primary"
|
|
|
|
type="primary"
|
|
|
|
htmlType="submit"
|
|
|
|
htmlType="submit"
|
|
|
|
className="login-form-button"
|
|
|
|
block
|
|
|
|
|
|
|
|
loading={this.state.loading}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
Log in
|
|
|
|
Log in
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
|
|
<Col span={4} offset={10}></Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const WrappedNormalLoginForm = withConfigContext(
|
|
|
|
|
|
|
|
Form.create({ name: 'normal_login' })(NormalLoginForm),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default withConfigContext(Login);
|
|
|
|
export default withConfigContext(Login);
|
|
|
|