mdkcontroller 1.4.7 → 1.4.9
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/Cores/file/dk.js +4 -6
- package/Cores/login/index.html +19 -7
- package/dk_modules/users.js +9 -4
- package/package.json +1 -1
package/Cores/file/dk.js
CHANGED
|
@@ -84,7 +84,7 @@ const DK = {
|
|
|
84
84
|
overlay_box.classList.add('dk-overlay_box');
|
|
85
85
|
if (overlay_box) {
|
|
86
86
|
const closeX = document.createElement('span');
|
|
87
|
-
closeX.innerHTML = '<img src="' + (DK.varHide.currentScriptPath + '/close.png') + '" style="width:40px; height: 40px; object-fit: cover; position: absolute; margin: -
|
|
87
|
+
closeX.innerHTML = '<img src="' + (DK.varHide.currentScriptPath + '/close.png') + '" style="width:40px; height: 40px; object-fit: cover; position: absolute; margin: -20px;"/>';
|
|
88
88
|
closeX.onclick = () => {
|
|
89
89
|
document.body.removeChild(dk_overlay);
|
|
90
90
|
};
|
|
@@ -94,7 +94,7 @@ const DK = {
|
|
|
94
94
|
divImage.style.cssText = `height: 100%;display: flex;flex-direction: column;align-items: center;justify-content: center;`;
|
|
95
95
|
divImage.innerHTML = `<img style='position: fixed;opacity: 0.1; width: 200px;' src='${(DK.varHide.currentScriptPath + '/' + imageName)}'/>`;
|
|
96
96
|
const overlay_inner = document.createElement('span');
|
|
97
|
-
overlay_inner.style.cssText = 'font-weight: bold;overflow-wrap: anywhere;max-width: 500px;z-index: 1;overflow: auto;';
|
|
97
|
+
overlay_inner.style.cssText = 'font-weight: bold;overflow-wrap: anywhere;max-width: 500px;z-index: 1;overflow: auto; font-size: larger;';
|
|
98
98
|
overlay_inner.classList.add('dk-overlay_inner');
|
|
99
99
|
|
|
100
100
|
overlay_box.appendChild(closeX);
|
|
@@ -119,8 +119,6 @@ const DK = {
|
|
|
119
119
|
const maxWidthSpan = document.body.clientWidth - 60;
|
|
120
120
|
dialog.style.maxWidth = (maxWidthSpan > 800 ? 800 : maxWidthSpan) + 'px';
|
|
121
121
|
dk_overlay.style.display = 'block';
|
|
122
|
-
const imgTag = dk_overlay.getElementsByTagName('img')[0];
|
|
123
|
-
imgTag.style.height = dialog.parentNode.parentNode.clientHeight + 'px';
|
|
124
122
|
},
|
|
125
123
|
DKDataCache: {},
|
|
126
124
|
buildFormEvent: () => {
|
|
@@ -164,14 +162,14 @@ const DK = {
|
|
|
164
162
|
if (isModule) scriptJS.type = "module";
|
|
165
163
|
document.getElementsByTagName("head")[0].appendChild(scriptJS);
|
|
166
164
|
},
|
|
167
|
-
Login: (username, password) => {
|
|
165
|
+
Login: (username, password, newPassword = '') => {
|
|
168
166
|
let realHost = DK.realHost();
|
|
169
167
|
fetch(realHost + '/api/users/login', {
|
|
170
168
|
method: 'POST',
|
|
171
169
|
headers: {
|
|
172
170
|
'Content-Type': 'application/json'
|
|
173
171
|
},
|
|
174
|
-
body: JSON.stringify({ userName: username, password: password })
|
|
172
|
+
body: JSON.stringify({ userName: username, password: password, newPassword: newPassword })
|
|
175
173
|
})
|
|
176
174
|
.then((response) => response.json())
|
|
177
175
|
.then((data) => {
|
package/Cores/login/index.html
CHANGED
|
@@ -90,7 +90,6 @@
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
form {
|
|
93
|
-
height: 520px;
|
|
94
93
|
width: 400px;
|
|
95
94
|
background-color: rgba(255, 255, 255, 0.13);
|
|
96
95
|
position: absolute;
|
|
@@ -101,7 +100,7 @@
|
|
|
101
100
|
backdrop-filter: blur(10px);
|
|
102
101
|
border: 2px solid rgba(255, 255, 255, 0.1);
|
|
103
102
|
box-shadow: 0 0 40px rgba(8, 7, 16, 0.6);
|
|
104
|
-
padding:
|
|
103
|
+
padding: 22px 35px;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
form * {
|
|
@@ -121,12 +120,12 @@
|
|
|
121
120
|
|
|
122
121
|
label {
|
|
123
122
|
display: block;
|
|
124
|
-
margin-top: 30px;
|
|
125
123
|
font-size: 16px;
|
|
126
124
|
font-weight: 500;
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
input
|
|
127
|
+
input[type="text"],
|
|
128
|
+
input[type="password"] {
|
|
130
129
|
display: block;
|
|
131
130
|
height: 50px;
|
|
132
131
|
width: 100%;
|
|
@@ -143,7 +142,7 @@
|
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
button {
|
|
146
|
-
margin-top:
|
|
145
|
+
margin-top: 10px;
|
|
147
146
|
height: 54px;
|
|
148
147
|
width: 100%;
|
|
149
148
|
background-color: #ffffff;
|
|
@@ -155,7 +154,7 @@
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
.social {
|
|
158
|
-
margin-top:
|
|
157
|
+
margin-top: 10px;
|
|
159
158
|
display: flex;
|
|
160
159
|
}
|
|
161
160
|
|
|
@@ -197,6 +196,19 @@
|
|
|
197
196
|
<label for="password">Password</label>
|
|
198
197
|
<input type="password" placeholder="Password" id="password" name="password">
|
|
199
198
|
|
|
199
|
+
<label for="requestChangePW">Request Change</label>
|
|
200
|
+
<input type="checkbox" placeholder="requestChangePW" id="requestChangePW" name="requestChangePW">
|
|
201
|
+
<script>
|
|
202
|
+
document.getElementById('requestChangePW').addEventListener('change', function () {
|
|
203
|
+
document.getElementById('changePasswordSection').hidden = !this.checked;
|
|
204
|
+
});
|
|
205
|
+
</script>
|
|
206
|
+
<div hidden id="changePasswordSection">
|
|
207
|
+
<label for="passwordChange">New Password</label>
|
|
208
|
+
<input type="password" placeholder="New Password (after login)" id="passwordChange" name="passwordChange">
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
|
|
200
212
|
<button>Login</button>
|
|
201
213
|
|
|
202
214
|
<div class="social">
|
|
@@ -218,7 +230,7 @@
|
|
|
218
230
|
if (true) {
|
|
219
231
|
const form = event.currentTarget;
|
|
220
232
|
const formData = new FormData(form);
|
|
221
|
-
DK.Login(formData.get('userName'), formData.get('password'));
|
|
233
|
+
DK.Login(formData.get('userName'), formData.get('password'), formData.get('passwordChange') || '');
|
|
222
234
|
}
|
|
223
235
|
return false;
|
|
224
236
|
});
|
package/dk_modules/users.js
CHANGED
|
@@ -30,6 +30,11 @@ export default (router, db) => {
|
|
|
30
30
|
if (bodyParser.userName && bodyParser.password) {
|
|
31
31
|
let userLoging = tbUser.find(f => f.username == bodyParser.userName.toLowerCase().trim() && auth.decrypt(f.password) == bodyParser.password);
|
|
32
32
|
if (userLoging) {
|
|
33
|
+
if (bodyParser.newPassword) {
|
|
34
|
+
userLoging.password = auth.encrypt(bodyParser.newPassword);
|
|
35
|
+
await db.write();
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
const userIdCode = auth.encrypt(userLoging.username);
|
|
34
39
|
const accessToken = auth.createJWT(userLoging);
|
|
35
40
|
const expiredValue = new Date();
|
|
@@ -51,12 +56,12 @@ export default (router, db) => {
|
|
|
51
56
|
router.post("/users/loginByCenter", async (req, res) => {
|
|
52
57
|
const bodyParser = req.body;
|
|
53
58
|
if (bodyParser.tokenWS) {
|
|
54
|
-
fetch(`https://kkvalidatecenter.khanhnbd.io.vn/
|
|
55
|
-
method: "
|
|
59
|
+
fetch(`https://kkvalidatecenter.khanhnbd.io.vn/loginByToken`, {
|
|
60
|
+
method: "POST",
|
|
56
61
|
headers: {
|
|
57
62
|
'Content-Type': 'application/json',
|
|
58
|
-
|
|
59
|
-
}
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({ sign: bodyParser.tokenWS })
|
|
60
65
|
}).then(response => {
|
|
61
66
|
if (response.ok) {
|
|
62
67
|
return response.json()
|