kitchen-simulator 5.0.0-test.17 → 5.0.0-test.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -18
- package/src/@history.js +3 -0
- package/src/CrossSignOn.jsx +94 -0
- package/src/KitchenConfigurator.jsx +1526 -0
- package/src/KitchenConfiguratorApp.jsx +1 -1
- package/src/_KitchenConfigurator.jsx +3 -91
- package/src/components/atoms/Snackbar/index.jsx +43 -0
- package/src/components/atoms/radio-button/index.jsx +20 -0
- package/src/components/atoms/radio-button/styles.js +56 -0
- package/src/components/button/MainButton.jsx +157 -0
- package/src/components/button/ToggleMeasureButton.jsx +65 -0
- package/src/components/catalog-view/catalog-breadcrumb.jsx +53 -0
- package/src/components/catalog-view/catalog-item.jsx +229 -0
- package/src/components/catalog-view/catalog-list.jsx +173 -0
- package/src/components/catalog-view/catalog-page-item.jsx +110 -0
- package/src/components/catalog-view/catalog-turn-back-page-item.jsx +80 -0
- package/src/components/configurator/custom-configurator.jsx +77 -0
- package/src/components/configurator/project-configurator.jsx +120 -0
- package/src/components/content.jsx +136 -0
- package/src/components/export.js +36 -0
- package/src/components/firstsetting/button/styles.js +223 -0
- package/src/components/firstsetting/export.js +9 -0
- package/src/components/firstsetting/firstsetting-content-button.jsx +198 -0
- package/src/components/firstsetting/firstsetting-toggle-button.jsx +101 -0
- package/src/components/firstsetting/firstsetting.jsx +814 -0
- package/src/components/footerbar/button/ControlButton.jsx +43 -0
- package/src/components/footerbar/button/DirectionButton.jsx +54 -0
- package/src/components/footerbar/button/DirectionPanSpinButton.jsx +36 -0
- package/src/components/footerbar/button/ToggleButton.jsx +58 -0
- package/src/components/footerbar/button/ToggleConvertButton.jsx +48 -0
- package/src/components/footerbar/button/ToggleMeasureButton.jsx +33 -0
- package/src/components/footerbar/button/styles.js +217 -0
- package/src/components/footerbar/export.js +9 -0
- package/src/components/footerbar/footer-content-button.jsx +198 -0
- package/src/components/footerbar/footer-toggle-button.jsx +101 -0
- package/src/components/footerbar/footerbar.jsx +1103 -0
- package/src/components/footerbar/styles.js +263 -0
- package/src/components/header/button/MenuButton.jsx +46 -0
- package/src/components/header/button/SaveButton.jsx +54 -0
- package/src/components/header/button/styles.js +181 -0
- package/src/components/header/export.js +5 -0
- package/src/components/header/header.jsx +631 -0
- package/src/components/header/header.style.css +47 -0
- package/src/components/header/styles.js +320 -0
- package/src/components/login/Login.js +77 -0
- package/src/components/login/LoginForm/index.js +108 -0
- package/src/components/login/Register.js +82 -0
- package/src/components/login/RegisterForm/index.js +171 -0
- package/src/components/login/jwtService.js +201 -0
- package/src/components/login/style.css +158 -0
- package/src/components/login/style.scss +260 -0
- package/src/components/molecules/slider/index.jsx +15 -0
- package/src/components/molecules/slider/styles.js +0 -0
- package/src/components/molecules/slider/styles.scss +3 -0
- package/src/components/myprojects/export.js +5 -0
- package/src/components/myprojects/index.jsx +445 -0
- package/src/components/myprojects/styles.js +241 -0
- package/src/components/sidebar/custom-accordion.jsx +48 -0
- package/src/components/sidebar/export.js +15 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/attributes-editor.jsx +73 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/confirm-popup.jsx +101 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/hole-attributes-editor.jsx +149 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/item-attributes-editor.jsx +316 -0
- package/src/components/sidebar/panel-element-editor/attributes-editor/line-attributes-editor.jsx +108 -0
- package/src/components/sidebar/panel-element-editor/element-editor.jsx +1070 -0
- package/src/components/sidebar/panel-element-editor/multi-elements-editor.jsx +0 -0
- package/src/components/sidebar/panel-element-editor/panel-element-editor.jsx +104 -0
- package/src/components/sidebar/panel-element-editor/panel-multi-elements-editor.jsx +155 -0
- package/src/components/sidebar/panel-group-editor.jsx +272 -0
- package/src/components/sidebar/panel-groups.jsx +310 -0
- package/src/components/sidebar/panel-guides.jsx +192 -0
- package/src/components/sidebar/panel-layer-elements.jsx +298 -0
- package/src/components/sidebar/panel-layers.jsx +381 -0
- package/src/components/sidebar/panel.jsx +71 -0
- package/src/components/sidebar/sidebar.jsx +106 -0
- package/src/components/sidebar/toolbar-panel.jsx +139 -0
- package/src/components/sign/export.js +7 -0
- package/src/components/sign/main/index.jsx +523 -0
- package/src/components/sign/main/styles.js +163 -0
- package/src/components/style/button.jsx +95 -0
- package/src/components/style/cancel-button.jsx +20 -0
- package/src/components/style/content-container.jsx +29 -0
- package/src/components/style/content-title.jsx +20 -0
- package/src/components/style/delete-button.jsx +23 -0
- package/src/components/style/export.jsx +48 -0
- package/src/components/style/form-block.jsx +13 -0
- package/src/components/style/form-color-input.jsx +27 -0
- package/src/components/style/form-label.jsx +15 -0
- package/src/components/style/form-number-input.jsx +196 -0
- package/src/components/style/form-number-input_2.jsx +191 -0
- package/src/components/style/form-select.jsx +38 -0
- package/src/components/style/form-slider.jsx +36 -0
- package/src/components/style/form-submit-button.jsx +23 -0
- package/src/components/style/form-text-input.jsx +65 -0
- package/src/components/toolbar/button/ControlButton.jsx +41 -0
- package/src/components/toolbar/button/DirectionButton.jsx +34 -0
- package/src/components/toolbar/button/RightButton.jsx +103 -0
- package/src/components/toolbar/button/ToggleButton.jsx +41 -0
- package/src/components/toolbar/button/index.jsx +55 -0
- package/src/components/toolbar/button/styles.js +127 -0
- package/src/components/toolbar/components/DoorStyleMenu.jsx +103 -0
- package/src/components/toolbar/components/Pricing.jsx +126 -0
- package/src/components/toolbar/components/ReviewForQuote.jsx +635 -0
- package/src/components/toolbar/export.js +21 -0
- package/src/components/toolbar/main/Alert.js +122 -0
- package/src/components/toolbar/main/TakePictureModal.jsx +104 -0
- package/src/components/toolbar/main/confirm-popup.jsx +99 -0
- package/src/components/toolbar/main/index.jsx +5627 -0
- package/src/components/toolbar/main/lShaped.json +311 -0
- package/src/components/toolbar/main/longNarrow.json +238 -0
- package/src/components/toolbar/main/myComponents.js +123 -0
- package/src/components/toolbar/main/oRectangle.json +220 -0
- package/src/components/toolbar/main/rectangle.json +238 -0
- package/src/components/toolbar/main/style.css +107 -0
- package/src/components/toolbar/main/styles.js +696 -0
- package/src/components/toolbar/plugin-item.jsx +123 -0
- package/src/components/toolbar/popup/appliance/appliance-category/index.jsx +73 -0
- package/src/components/toolbar/popup/appliance/choose-appliance/index.jsx +102 -0
- package/src/components/toolbar/popup/appliance/index.jsx +83 -0
- package/src/components/toolbar/popup/autosaveprompt/index.jsx +150 -0
- package/src/components/toolbar/popup/autosaveprompt/styles.css +64 -0
- package/src/components/toolbar/popup/autosaveprompt/styles.js +40 -0
- package/src/components/toolbar/popup/cabinet/cabinet-category/index.jsx +73 -0
- package/src/components/toolbar/popup/cabinet/choose-product/index.jsx +119 -0
- package/src/components/toolbar/popup/cabinet/index.jsx +85 -0
- package/src/components/toolbar/popup/doorStyle/choose-style/index.jsx +63 -0
- package/src/components/toolbar/popup/doorStyle/index.jsx +71 -0
- package/src/components/toolbar/popup/doorStyle/style-category/index.jsx +139 -0
- package/src/components/toolbar/popup/downloadsummary/downloadSummaryContext.js +2 -0
- package/src/components/toolbar/popup/downloadsummary/downloadSummaryTemp.jsx +157 -0
- package/src/components/toolbar/popup/downloadsummary/index.jsx +643 -0
- package/src/components/toolbar/popup/downloadsummary/show2D/show2DView.jsx +51 -0
- package/src/components/toolbar/popup/downloadsummary/show2D/viewer2DDownLoad.jsx +175 -0
- package/src/components/toolbar/popup/downloadsummary/show3D/show3DView.jsx +283 -0
- package/src/components/toolbar/popup/downloadsummary/show3D/viewer3DDownLoad.jsx +2257 -0
- package/src/components/toolbar/popup/downloadsummary/showCabinetInfo.js +93 -0
- package/src/components/toolbar/popup/downloadsummary/showElevation/showElevationView.jsx +132 -0
- package/src/components/toolbar/popup/downloadsummary/showElevation/viewer3DElevationDownload.jsx +2198 -0
- package/src/components/toolbar/popup/downloadsummary/showElevation/viewerElevationDownload.jsx +152 -0
- package/src/components/toolbar/popup/downloadsummary/showWarranty.jsx +149 -0
- package/src/components/toolbar/popup/downloadsummary/styles.css +177 -0
- package/src/components/toolbar/popup/downloadsummary/styles.js +453 -0
- package/src/components/toolbar/popup/finishingtouch/category/index.jsx +34 -0
- package/src/components/toolbar/popup/finishingtouch/index.jsx +58 -0
- package/src/components/toolbar/popup/finishingtouch/material-edit.jsx +112 -0
- package/src/components/toolbar/popup/finishingtouch/product/index.jsx +116 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/confirm-popup.jsx +101 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/index.jsx +254 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/lShaped.json +311 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/longNarrow.json +238 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/oRectangle.json +220 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/rectangle.json +238 -0
- package/src/components/toolbar/popup/floorplan/choose-floor/styles.js +86 -0
- package/src/components/toolbar/popup/floorplan/floor-category/index.jsx +109 -0
- package/src/components/toolbar/popup/floorplan/index.jsx +60 -0
- package/src/components/toolbar/popup/index.jsx +241 -0
- package/src/components/toolbar/popup/newproject/index.jsx +59 -0
- package/src/components/toolbar/popup/newproject/styles.css +64 -0
- package/src/components/toolbar/popup/newproject/styles.js +41 -0
- package/src/components/toolbar/popup/product/appliance.jsx +54 -0
- package/src/components/toolbar/popup/product/cabinetproduct.jsx +15 -0
- package/src/components/toolbar/popup/product/doorstyle.jsx +58 -0
- package/src/components/toolbar/popup/product/doorstyleproduct.jsx +47 -0
- package/src/components/toolbar/popup/product/floor.jsx +36 -0
- package/src/components/toolbar/popup/product/floorproduct.jsx +42 -0
- package/src/components/toolbar/popup/product/index.jsx +36 -0
- package/src/components/toolbar/popup/product/primary.jsx +77 -0
- package/src/components/toolbar/popup/product/productline.jsx +93 -0
- package/src/components/toolbar/popup/product/reviewItem.jsx +427 -0
- package/src/components/toolbar/popup/product/reviewMolding.jsx +310 -0
- package/src/components/toolbar/popup/product/style.css +54 -0
- package/src/components/toolbar/popup/product/styles.js +260 -0
- package/src/components/toolbar/popup/savedesign/FullPictureForm.jsx +146 -0
- package/src/components/toolbar/popup/savedesign/index.jsx +495 -0
- package/src/components/toolbar/popup/savedesign/savedesign.style.css +16 -0
- package/src/components/toolbar/popup/savedesign/styles.js +151 -0
- package/src/components/toolbar/popup/setDoorStyleOption/index.jsx +87 -0
- package/src/components/toolbar/popup/styles.js +909 -0
- package/src/components/toolbar/popup/submitforquote/AddToCartOptions.jsx +192 -0
- package/src/components/toolbar/popup/submitforquote/CustomerRequestsForm.jsx +96 -0
- package/src/components/toolbar/popup/submitforquote/SkipDesignerReview.jsx +54 -0
- package/src/components/toolbar/popup/submitforquote/StepDots.jsx +25 -0
- package/src/components/toolbar/popup/submitforquote/cart-choice.jsx +116 -0
- package/src/components/toolbar/popup/submitforquote/doorstyle-menus.js +38 -0
- package/src/components/toolbar/popup/submitforquote/index.jsx +698 -0
- package/src/components/toolbar/popup/submitforquote/styles.css +105 -0
- package/src/components/toolbar/popup/submitforquote/styles.js +294 -0
- package/src/components/toolbar/popup/submitprompt/index.jsx +89 -0
- package/src/components/toolbar/popup/submitprompt/styles.css +64 -0
- package/src/components/toolbar/popup/submitprompt/styles.js +42 -0
- package/src/components/toolbar/toolbar-button.jsx +90 -0
- package/src/components/toolbar/toolbar-load-button.jsx +36 -0
- package/src/components/toolbar/toolbar-save-button.jsx +32 -0
- package/src/components/tutorial-view/Modal.jsx +584 -0
- package/src/components/tutorial-view/style.css +111 -0
- package/src/components/tutorial-view/styles.js +65 -0
- package/src/components/wizardstep/button/styles.js +677 -0
- package/src/components/wizardstep/export.js +5 -0
- package/src/components/wizardstep/index.jsx +1372 -0
- package/src/components/wizardstep/styles.js +688 -0
- package/src/components/wizardstep/wizardstep-content-button.jsx +198 -0
- package/src/components/wizardstep/wizardstep-toggle-button.jsx +101 -0
- package/src/{_index.js → index.js} +4 -4
- package/src/renderer.jsx +466 -0
- package/src/actions/_export.js +0 -35
- package/src/components/_export.js +0 -11
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Input, Button, Row } from 'antd';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { API_SERVER_URL } from '../../../constants';
|
|
5
|
+
import history from '../../../@history';
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import '../style.css';
|
|
8
|
+
|
|
9
|
+
class RegisterForm extends React.Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.state = {
|
|
13
|
+
username: '',
|
|
14
|
+
userid: '',
|
|
15
|
+
role: 'customer',
|
|
16
|
+
password: '',
|
|
17
|
+
confirmPwd: ''
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
handleSubmit(e) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
|
|
24
|
+
const { confirmPwd, ...values } = this.state;
|
|
25
|
+
if (values.password !== confirmPwd) {
|
|
26
|
+
alert('The passwords do not match');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
axios
|
|
31
|
+
.post(`${API_SERVER_URL}/api/user/insert`, { ...values })
|
|
32
|
+
.then(response => {
|
|
33
|
+
if (response.data.success) {
|
|
34
|
+
alert('Successfully registered');
|
|
35
|
+
this.setState({
|
|
36
|
+
username: '',
|
|
37
|
+
userid: '',
|
|
38
|
+
role: 'customer',
|
|
39
|
+
password: '',
|
|
40
|
+
confirmPwd: ''
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
alert('Username already exists');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
handleUsernameChange(e) {
|
|
49
|
+
e.target.setCustomValidity('');
|
|
50
|
+
this.setState({ username: e.target.value });
|
|
51
|
+
}
|
|
52
|
+
handleUserIDChange(e) {
|
|
53
|
+
e.target.setCustomValidity('');
|
|
54
|
+
this.setState({ userid: e.target.value });
|
|
55
|
+
}
|
|
56
|
+
handleUserRoleChange(e) {
|
|
57
|
+
this.setState({ role: e.target.value });
|
|
58
|
+
}
|
|
59
|
+
handlePasswordChange(e) {
|
|
60
|
+
e.target.setCustomValidity('');
|
|
61
|
+
this.setState({ password: e.target.value });
|
|
62
|
+
}
|
|
63
|
+
handleConfirmChange(e) {
|
|
64
|
+
e.target.setCustomValidity('');
|
|
65
|
+
this.setState({ confirmPwd: e.target.value });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
handleInputInvalid(e, text) {
|
|
69
|
+
e.target.setCustomValidity('');
|
|
70
|
+
if (!e.target.validity.valid) {
|
|
71
|
+
e.target.setCustomValidity(text);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
render() {
|
|
76
|
+
const { username, userid, role, password, confirmPwd } = this.state;
|
|
77
|
+
const { type } = this.props;
|
|
78
|
+
return (
|
|
79
|
+
<form onSubmit={e => this.handleSubmit(e)} className="register-form">
|
|
80
|
+
<Row className="register-form-row">
|
|
81
|
+
<label className="form-label mb-0">Username</label>
|
|
82
|
+
<Input
|
|
83
|
+
onChange={e => this.handleUsernameChange(e)}
|
|
84
|
+
onInvalid={e =>
|
|
85
|
+
this.handleInputInvalid(e, 'Please enter your name')
|
|
86
|
+
}
|
|
87
|
+
placeholder="Username"
|
|
88
|
+
required
|
|
89
|
+
value={username}
|
|
90
|
+
/>
|
|
91
|
+
</Row>
|
|
92
|
+
<Row className="register-form-row">
|
|
93
|
+
<label className="form-label mb-0">User ID</label>
|
|
94
|
+
<Input
|
|
95
|
+
onChange={e => this.handleUserIDChange(e)}
|
|
96
|
+
onInvalid={e => this.handleInputInvalid(e, 'Please enter your ID.')}
|
|
97
|
+
placeholder="User ID"
|
|
98
|
+
required
|
|
99
|
+
value={userid}
|
|
100
|
+
/>
|
|
101
|
+
</Row>
|
|
102
|
+
<Row className="register-form-row">
|
|
103
|
+
<label className="form-label mb-0">User Role</label>
|
|
104
|
+
<select onChange={e => this.handleUserRoleChange(e)} value={role}>
|
|
105
|
+
<option value="customer"> customer </option>
|
|
106
|
+
<option value="designer"> designer </option>
|
|
107
|
+
</select>
|
|
108
|
+
</Row>
|
|
109
|
+
<Row className="register-form-row">
|
|
110
|
+
<label className="form-label mb-0">Password</label>
|
|
111
|
+
<Input
|
|
112
|
+
onChange={e => this.handlePasswordChange(e)}
|
|
113
|
+
onInvalid={e =>
|
|
114
|
+
this.handleInputInvalid(e, 'Please confirm your password.')
|
|
115
|
+
}
|
|
116
|
+
type="password"
|
|
117
|
+
placeholder="Password"
|
|
118
|
+
value={password}
|
|
119
|
+
/>
|
|
120
|
+
</Row>
|
|
121
|
+
<Row className="register-form-row">
|
|
122
|
+
<label className="form-label mb-0">Confirm</label>
|
|
123
|
+
<Input
|
|
124
|
+
onChange={e => this.handleConfirmChange(e)}
|
|
125
|
+
onInvalid={e =>
|
|
126
|
+
this.handleInputInvalid(e, 'Please confirm your password.')
|
|
127
|
+
}
|
|
128
|
+
type="password"
|
|
129
|
+
placeholder="Confirm Password"
|
|
130
|
+
value={confirmPwd}
|
|
131
|
+
/>
|
|
132
|
+
</Row>
|
|
133
|
+
<Row className="login-form-row">
|
|
134
|
+
<div className="divider">-</div>
|
|
135
|
+
</Row>
|
|
136
|
+
<div
|
|
137
|
+
className="form-actions"
|
|
138
|
+
style={{
|
|
139
|
+
width: '90%',
|
|
140
|
+
display: 'flex',
|
|
141
|
+
justifyContent: 'space-around'
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<Link
|
|
145
|
+
className="register-link-btn"
|
|
146
|
+
to=""
|
|
147
|
+
onClick={e => history.goBack()}
|
|
148
|
+
>
|
|
149
|
+
{' '}
|
|
150
|
+
Back{' '}
|
|
151
|
+
</Link>
|
|
152
|
+
|
|
153
|
+
<Button
|
|
154
|
+
type="primary"
|
|
155
|
+
htmlType="submit"
|
|
156
|
+
className="login-form-button"
|
|
157
|
+
>
|
|
158
|
+
{type === 'register' ? 'Register' : 'Add User'}
|
|
159
|
+
</Button>
|
|
160
|
+
|
|
161
|
+
<Link className="register-link-btn" to="/login">
|
|
162
|
+
{' '}
|
|
163
|
+
Sign In{' '}
|
|
164
|
+
</Link>
|
|
165
|
+
</div>
|
|
166
|
+
</form>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export default RegisterForm;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import jwtDecode from 'jwt-decode';
|
|
3
|
+
import { API_SERVER_URL } from '../../constants';
|
|
4
|
+
|
|
5
|
+
class EventEmitter {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.events = {};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
_getEventListByName(eventName) {
|
|
11
|
+
if (typeof this.events[eventName] === 'undefined') {
|
|
12
|
+
this.events[eventName] = new Set();
|
|
13
|
+
}
|
|
14
|
+
return this.events[eventName];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
on(eventName, fn) {
|
|
18
|
+
this._getEventListByName(eventName).add(fn);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
once(eventName, fn) {
|
|
22
|
+
const self = this;
|
|
23
|
+
|
|
24
|
+
const onceFn = function (...args) {
|
|
25
|
+
self.removeListener(eventName, onceFn);
|
|
26
|
+
fn.apply(self, args);
|
|
27
|
+
};
|
|
28
|
+
this.on(eventName, onceFn);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
emit(eventName, ...args) {
|
|
32
|
+
this._getEventListByName(eventName).forEach(
|
|
33
|
+
function (fn) {
|
|
34
|
+
fn.apply(this, args);
|
|
35
|
+
}.bind(this)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
removeListener(eventName, fn) {
|
|
40
|
+
this._getEventListByName(eventName).delete(fn);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class jwtService extends EventEmitter {
|
|
45
|
+
init() {
|
|
46
|
+
// this.setInterceptors();
|
|
47
|
+
this.handleAuthentication();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setInterceptors() {
|
|
51
|
+
axios.interceptors.response.use(
|
|
52
|
+
response => {
|
|
53
|
+
return response;
|
|
54
|
+
},
|
|
55
|
+
err => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
console.log(err);
|
|
58
|
+
if (
|
|
59
|
+
err.response.status === 401 &&
|
|
60
|
+
err.config &&
|
|
61
|
+
!err.config.__isRetryRequest
|
|
62
|
+
) {
|
|
63
|
+
// if ( err)
|
|
64
|
+
// if you ever get an unauthorized response, logout the user
|
|
65
|
+
this.emit(
|
|
66
|
+
'onAutoLogout',
|
|
67
|
+
'Invalid access_token! There is a problem with Database.'
|
|
68
|
+
);
|
|
69
|
+
this.setSession(null);
|
|
70
|
+
this.setUser(null);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// throw err;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
handleAuthentication() {
|
|
80
|
+
let access_token = this.getAccessToken();
|
|
81
|
+
|
|
82
|
+
if (!access_token) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (this.isAuthTokenValid(access_token)) {
|
|
86
|
+
this.setSession(access_token);
|
|
87
|
+
this.emit('onAutoLogin', true);
|
|
88
|
+
} else {
|
|
89
|
+
this.setSession(null);
|
|
90
|
+
this.emit('onAutoLogout', 'access_token expired');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
createUser(data) {
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
axios.post('/api/auth/register', data).then(response => {
|
|
97
|
+
if (response.data.user) {
|
|
98
|
+
this.setUser(response.data.user);
|
|
99
|
+
this.setSession(response.data.access_token);
|
|
100
|
+
resolve(response.data.user);
|
|
101
|
+
} else {
|
|
102
|
+
reject(response.data.error);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
signInWithEmailAndPassword(values) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
axios
|
|
111
|
+
.post(`${API_SERVER_URL}/api/user/login`, {
|
|
112
|
+
values
|
|
113
|
+
})
|
|
114
|
+
.then(response => {
|
|
115
|
+
if (response.data.user) {
|
|
116
|
+
this.setUser(response.data.user);
|
|
117
|
+
this.setSession(response.data.token);
|
|
118
|
+
resolve(response.data.user);
|
|
119
|
+
} else {
|
|
120
|
+
reject(response.data.error);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
signInWithToken() {
|
|
127
|
+
return new Promise((resolve, reject) => {
|
|
128
|
+
axios
|
|
129
|
+
.post(`${API_SERVER_URL}/api/user/access-token`, {
|
|
130
|
+
data: {
|
|
131
|
+
access_token: this.getAccessToken()
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
.then(response => {
|
|
135
|
+
if (response.data.user) {
|
|
136
|
+
// this.emit('onLoginSuccess', {message: 'You log in with token.', variant: 'success'});
|
|
137
|
+
this.setUser(response.data.user);
|
|
138
|
+
this.setSession(response.data.access_token);
|
|
139
|
+
resolve(response.data.user);
|
|
140
|
+
} else {
|
|
141
|
+
reject(response.data.error);
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
.catch(err => {
|
|
145
|
+
console.log(err);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
updateUserData(user) {
|
|
151
|
+
return axios.post('/api/auth/user/update', {
|
|
152
|
+
user: user
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setSession(access_token) {
|
|
157
|
+
if (access_token) {
|
|
158
|
+
sessionStorage.setItem('jwt_access_token', access_token);
|
|
159
|
+
// axios.defaults.headers.common['Authorization'] = 'Bearer ' + access_token;
|
|
160
|
+
} else {
|
|
161
|
+
sessionStorage.removeItem('jwt_access_token');
|
|
162
|
+
// delete axios.defaults.headers.common['Authorization'];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
setUser(user) {
|
|
166
|
+
if (user) {
|
|
167
|
+
sessionStorage.setItem('jwt_access_user', JSON.stringify(user));
|
|
168
|
+
} else {
|
|
169
|
+
sessionStorage.removeItem('jwt_access_user');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
getUser() {
|
|
173
|
+
return JSON.parse(sessionStorage.getItem('jwt_access_user'));
|
|
174
|
+
}
|
|
175
|
+
logout() {
|
|
176
|
+
this.setSession(null);
|
|
177
|
+
this.setUser(null);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
isAuthTokenValid(access_token) {
|
|
181
|
+
if (!access_token) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const decoded = jwtDecode(access_token);
|
|
185
|
+
const currentTime = Date.now() / 1000;
|
|
186
|
+
if (decoded.exp < currentTime) {
|
|
187
|
+
console.warn('access token expired');
|
|
188
|
+
return false;
|
|
189
|
+
} else {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
getAccessToken() {
|
|
195
|
+
return window.sessionStorage.getItem('jwt_access_token');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const instance = new jwtService();
|
|
200
|
+
|
|
201
|
+
export default instance;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
.login-form {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
5
|
+
height: 65%;
|
|
6
|
+
}
|
|
7
|
+
.register-form {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
align-items: center;
|
|
11
|
+
height: 70%;
|
|
12
|
+
}
|
|
13
|
+
.login-form-row {
|
|
14
|
+
line-height: 30px;
|
|
15
|
+
margin-bottom: 18px;
|
|
16
|
+
margin-top: 13px;
|
|
17
|
+
width: 80%;
|
|
18
|
+
}
|
|
19
|
+
.register-form-row {
|
|
20
|
+
line-height: 30px;
|
|
21
|
+
margin-top: 7px;
|
|
22
|
+
width: 80%;
|
|
23
|
+
}
|
|
24
|
+
.login-form-row-check {
|
|
25
|
+
line-height: 30px;
|
|
26
|
+
margin-bottom: 10px;
|
|
27
|
+
margin-top: 13px;
|
|
28
|
+
width: 80%;
|
|
29
|
+
text-align: center;
|
|
30
|
+
}
|
|
31
|
+
.login-form-button {
|
|
32
|
+
height: 32px;
|
|
33
|
+
line-height: 1.499;
|
|
34
|
+
position: relative;
|
|
35
|
+
display: inline-block;
|
|
36
|
+
font-weight: 400;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
text-align: center;
|
|
39
|
+
border: 1px solid transparent;
|
|
40
|
+
-webkit-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
|
|
41
|
+
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
-webkit-transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
44
|
+
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
45
|
+
-webkit-user-select: none;
|
|
46
|
+
-moz-user-select: none;
|
|
47
|
+
-ms-user-select: none;
|
|
48
|
+
user-select: none;
|
|
49
|
+
-ms-touch-action: manipulation;
|
|
50
|
+
touch-action: manipulation;
|
|
51
|
+
height: 32px;
|
|
52
|
+
padding: 0 15px;
|
|
53
|
+
font-size: 14px;
|
|
54
|
+
border-radius: 4px;
|
|
55
|
+
color: white;
|
|
56
|
+
background-color: #1890ff;
|
|
57
|
+
border-color: #d9d9d9;
|
|
58
|
+
}
|
|
59
|
+
.login-form-button:not([disabled]):hover {
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
}
|
|
62
|
+
.login-form-button:hover,
|
|
63
|
+
.login-form-button:focus {
|
|
64
|
+
color: #fff;
|
|
65
|
+
background-color: #40a9ff;
|
|
66
|
+
border-color: #40a9ff;
|
|
67
|
+
}
|
|
68
|
+
.register-link-btn {
|
|
69
|
+
color: #1890ff;
|
|
70
|
+
padding-top: 8px;
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
.register-link-btn:hover,
|
|
75
|
+
.register-link-btn:focus {
|
|
76
|
+
color: #40a9ff;
|
|
77
|
+
text-decoration: underline;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.form-label {
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
color: rgba(0, 0, 0, 0.65);
|
|
83
|
+
}
|
|
84
|
+
.form-actions {
|
|
85
|
+
padding-top: 7px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.login-form-row input,
|
|
89
|
+
.register-form-row input {
|
|
90
|
+
padding-left: 10px;
|
|
91
|
+
border: 1px solid #2299dd;
|
|
92
|
+
border-left: 3px solid #2299dd;
|
|
93
|
+
width: 100%;
|
|
94
|
+
height: 25px;
|
|
95
|
+
color: black;
|
|
96
|
+
}
|
|
97
|
+
.register-form-row select {
|
|
98
|
+
padding-left: 10px;
|
|
99
|
+
border: 1px solid #2299dd;
|
|
100
|
+
border-left: 3px solid #2299dd;
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 25px;
|
|
103
|
+
color: black;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.login {
|
|
107
|
+
position: fixed;
|
|
108
|
+
width: 100%;
|
|
109
|
+
height: 100%;
|
|
110
|
+
background-size: cover;
|
|
111
|
+
background-position: center center;
|
|
112
|
+
overflow-y: auto;
|
|
113
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
|
|
114
|
+
'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial,
|
|
115
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
116
|
+
}
|
|
117
|
+
.login__block__inner {
|
|
118
|
+
display: flex;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
align-items: center;
|
|
121
|
+
}
|
|
122
|
+
.login__block__form {
|
|
123
|
+
background-color: white;
|
|
124
|
+
border-radius: 10px;
|
|
125
|
+
width: 390px;
|
|
126
|
+
height: 420px;
|
|
127
|
+
}
|
|
128
|
+
.register__block__form {
|
|
129
|
+
background-color: white;
|
|
130
|
+
border-radius: 10px;
|
|
131
|
+
width: 390px;
|
|
132
|
+
height: 510px;
|
|
133
|
+
}
|
|
134
|
+
.login__block__promo {
|
|
135
|
+
padding: 0 0 2.61rem;
|
|
136
|
+
max-width: 61.53rem;
|
|
137
|
+
font-size: 14px;
|
|
138
|
+
line-height: 2rem;
|
|
139
|
+
text-align: center;
|
|
140
|
+
margin: 0 auto;
|
|
141
|
+
}
|
|
142
|
+
.login__block {
|
|
143
|
+
padding-top: 100px;
|
|
144
|
+
}
|
|
145
|
+
.text-white {
|
|
146
|
+
color: white;
|
|
147
|
+
}
|
|
148
|
+
.text-center {
|
|
149
|
+
text-align: center;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.divider {
|
|
153
|
+
width: 100%;
|
|
154
|
+
height: 1px;
|
|
155
|
+
color: white;
|
|
156
|
+
user-select: none;
|
|
157
|
+
background-color: rgba(0, 0, 0, 0.65);
|
|
158
|
+
}
|