w-web-api 1.0.29 → 1.0.30
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/dist/index.tmp +3 -1
- package/dist/js/app-legacy.9b4e9f9b.js +2 -0
- package/dist/js/app-legacy.9b4e9f9b.js.map +1 -0
- package/dist/js/app.9b4e9f9b.js +2 -0
- package/dist/js/app.9b4e9f9b.js.map +1 -0
- package/dist/js/{chunk-vendors.c0c4267e.js → chunk-vendors-legacy.2a4fa50d.js} +2 -2
- package/dist/js/{chunk-vendors.c0c4267e.js.map → chunk-vendors-legacy.2a4fa50d.js.map} +1 -1
- package/dist/js/{chunk-vendors-legacy.c0c4267e.js → chunk-vendors.2a4fa50d.js} +2 -2
- package/dist/js/chunk-vendors.2a4fa50d.js.map +1 -0
- package/dist/w-web-api.umd.js +2 -2
- package/dist/w-web-api.umd.js.map +1 -1
- package/docs/WWebApi.html +41 -1
- package/docs/WWebApi.mjs.html +30 -4
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/public/index.html +7 -0
- package/server/WWebApi.mjs +29 -3
- package/src/App.vue +17 -2
- package/src/store/mutations.mjs +6 -13
- package/srv.mjs +3 -1
- package/tableTags-web-api.json +1 -1
- package/dist/js/app-legacy.86198344.js +0 -2
- package/dist/js/app-legacy.86198344.js.map +0 -1
- package/dist/js/app.86198344.js +0 -2
- package/dist/js/app.86198344.js.map +0 -1
- package/dist/js/chunk-vendors-legacy.c0c4267e.js.map +0 -1
package/docs/WWebApi.html
CHANGED
|
@@ -721,6 +721,46 @@
|
|
|
721
721
|
</tr>
|
|
722
722
|
|
|
723
723
|
|
|
724
|
+
|
|
725
|
+
<tr>
|
|
726
|
+
|
|
727
|
+
<td class="name"><code>urlRedirect</code></td>
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
<td class="type">
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
<span class="param-type">String</span>
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
</td>
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
<td class="attributes">
|
|
742
|
+
|
|
743
|
+
<optional><br>
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
</td>
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
<td class="default">
|
|
754
|
+
|
|
755
|
+
<code>''</code>
|
|
756
|
+
|
|
757
|
+
</td>
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
<td class="description last"><p>輸入錯誤時自動轉址字串,提供站台例如無法登入或驗證失敗時須自動轉址,預設''</p></td>
|
|
761
|
+
</tr>
|
|
762
|
+
|
|
763
|
+
|
|
724
764
|
</tbody>
|
|
725
765
|
</table>
|
|
726
766
|
|
|
@@ -809,7 +849,7 @@
|
|
|
809
849
|
<br class="clear">
|
|
810
850
|
|
|
811
851
|
<footer>
|
|
812
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Nov 02 2023
|
|
852
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Nov 02 2023 22:58:48 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
813
853
|
</footer>
|
|
814
854
|
|
|
815
855
|
<script>prettyPrint();</script>
|
package/docs/WWebApi.mjs.html
CHANGED
|
@@ -48,10 +48,8 @@
|
|
|
48
48
|
<pre class="prettyprint source linenums"><code>import path from 'path'
|
|
49
49
|
import fs from 'fs'
|
|
50
50
|
import get from 'lodash/get'
|
|
51
|
-
// import map from 'lodash/map'
|
|
52
51
|
import each from 'lodash/each'
|
|
53
52
|
import keys from 'lodash/keys'
|
|
54
|
-
// import cloneDeep from 'lodash/cloneDeep'
|
|
55
53
|
import j2o from 'wsemi/src/j2o.mjs'
|
|
56
54
|
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
57
55
|
import isestr from 'wsemi/src/isestr.mjs'
|
|
@@ -67,6 +65,7 @@ import strdelright from 'wsemi/src/strdelright.mjs'
|
|
|
67
65
|
import pm2resolve from 'wsemi/src/pm2resolve.mjs'
|
|
68
66
|
import b642str from 'wsemi/src/b642str.mjs'
|
|
69
67
|
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
68
|
+
import fsIsFile from 'wsemi/src/fsIsFile.mjs'
|
|
70
69
|
import replace from 'wsemi/src/replace.mjs'
|
|
71
70
|
import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
|
|
72
71
|
import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
@@ -91,6 +90,7 @@ import ds from '../src/schema/index.mjs'
|
|
|
91
90
|
* @param {Object} [opt.webDescription={}] 輸入站台描述物件,至少包含語系eng與cht鍵的名稱,預設{}
|
|
92
91
|
* @param {String} [opt.webLogo=''] 輸入站台logo字串,採base64格式,預設''
|
|
93
92
|
* @param {String} [opt.subfolder=''] 輸入站台所在子目錄字串,提供站台位於內網採反向代理進行服務時,故需支援位於子目錄情形,預設''
|
|
93
|
+
* @param {String} [opt.urlRedirect=''] 輸入錯誤時自動轉址字串,提供站台例如無法登入或驗證失敗時須自動轉址,預設''
|
|
94
94
|
* @returns {Object} 回傳物件,其內server為hapi伺服器實體,wsrv為w-converhp的伺服器事件物件,wsds為w-serv-webdata的伺服器事件物件,可監聽error事件
|
|
95
95
|
* @example
|
|
96
96
|
* import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
|
|
@@ -242,6 +242,10 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
|
|
245
|
+
//urlRedirect
|
|
246
|
+
let urlRedirect = get(opt, 'urlRedirect', '')
|
|
247
|
+
|
|
248
|
+
|
|
245
249
|
//WServOrm
|
|
246
250
|
let optWServOrm = {
|
|
247
251
|
bCheckUser,
|
|
@@ -279,7 +283,8 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
279
283
|
|
|
280
284
|
//check
|
|
281
285
|
if (!iseobj(userSelf)) {
|
|
282
|
-
console.log(`
|
|
286
|
+
console.log(`token`, token)
|
|
287
|
+
console.log(`can not find the user from token`)
|
|
283
288
|
return Promise.reject(`can not find the user from token`)
|
|
284
289
|
}
|
|
285
290
|
|
|
@@ -292,6 +297,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
292
297
|
//check
|
|
293
298
|
if (!b) {
|
|
294
299
|
console.log('userSelf', userSelf)
|
|
300
|
+
console.log(`user does not have permission`)
|
|
295
301
|
return Promise.reject(`user does not have permission`)
|
|
296
302
|
}
|
|
297
303
|
|
|
@@ -308,6 +314,8 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
308
314
|
|
|
309
315
|
//parsePayload
|
|
310
316
|
let parsePayload = async (req) => {
|
|
317
|
+
|
|
318
|
+
//inp
|
|
311
319
|
let inp = get(req, 'payload')
|
|
312
320
|
|
|
313
321
|
//to obj
|
|
@@ -318,6 +326,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
318
326
|
//check
|
|
319
327
|
if (!iseobj(inp)) {
|
|
320
328
|
console.log('inp', inp)
|
|
329
|
+
console.log(`invalid inp from req`)
|
|
321
330
|
return Promise.reject(`invalid inp from req`)
|
|
322
331
|
}
|
|
323
332
|
|
|
@@ -328,6 +337,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
328
337
|
if (!isestr(group)) {
|
|
329
338
|
console.log('inp', inp)
|
|
330
339
|
console.log('group', group)
|
|
340
|
+
console.log(`invalid group from inp`)
|
|
331
341
|
return Promise.reject(`invalid group from inp`)
|
|
332
342
|
}
|
|
333
343
|
|
|
@@ -338,6 +348,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
338
348
|
if (!isearr(apis)) {
|
|
339
349
|
console.log('inp', inp)
|
|
340
350
|
console.log('apis', apis)
|
|
351
|
+
console.log(`invalid apis from inp`)
|
|
341
352
|
return Promise.reject(`invalid apis from inp`)
|
|
342
353
|
}
|
|
343
354
|
|
|
@@ -396,6 +407,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
396
407
|
if (!isestr(group)) {
|
|
397
408
|
console.log('params', params)
|
|
398
409
|
console.log('group', group)
|
|
410
|
+
console.log(`invalid group`)
|
|
399
411
|
return Promise.reject(`invalid group`)
|
|
400
412
|
}
|
|
401
413
|
|
|
@@ -407,6 +419,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
407
419
|
if (!isearr(apis)) {
|
|
408
420
|
console.log('params', params)
|
|
409
421
|
console.log('apis', apis)
|
|
422
|
+
console.log(`invalid apis`)
|
|
410
423
|
return Promise.reject(`invalid apis`)
|
|
411
424
|
}
|
|
412
425
|
|
|
@@ -434,9 +447,18 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
434
447
|
let fnEntryOut = 'index.html'
|
|
435
448
|
try {
|
|
436
449
|
let fpEntryIn = path.resolve(pathStaticFiles, fnEntryIn)
|
|
450
|
+
if (!fsIsFile(fpEntryIn)) {
|
|
451
|
+
fpEntryIn = path.resolve(pathStaticFiles, fnEntryOut) //本機開發另使用html替代tmp
|
|
452
|
+
}
|
|
453
|
+
if (!fsIsFile(fpEntryIn)) {
|
|
454
|
+
console.log('fpEntryIn', fpEntryIn)
|
|
455
|
+
throw new Error(`invalid fpEntryIn`)
|
|
456
|
+
}
|
|
437
457
|
let fpEntryOut = path.resolve(pathStaticFiles, fnEntryOut)
|
|
438
458
|
let c = fs.readFileSync(fpEntryIn, 'utf8')
|
|
459
|
+
c = replace(c, '/mapi/', '{sfd}/') //方法同genEntry
|
|
439
460
|
c = replace(c, '{sfd}', subfolder)
|
|
461
|
+
c = replace(c, '{urlRedirect}', urlRedirect)
|
|
440
462
|
fs.writeFileSync(fpEntryOut, c, 'utf8')
|
|
441
463
|
}
|
|
442
464
|
catch (err) {
|
|
@@ -483,6 +505,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
483
505
|
if (!iseobj(user)) {
|
|
484
506
|
console.log('token', token)
|
|
485
507
|
console.log('[API]getUserByToken/check user: invalid user')
|
|
508
|
+
console.log(`token does not have permission`)
|
|
486
509
|
return Promise.reject(`token does not have permission`)
|
|
487
510
|
}
|
|
488
511
|
|
|
@@ -514,6 +537,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
514
537
|
if (!iseobj(user)) {
|
|
515
538
|
console.log('token', token)
|
|
516
539
|
console.log('[API]getAPIsList/check user: invalid user')
|
|
540
|
+
console.log(`token does not have permission`)
|
|
517
541
|
return Promise.reject(`token does not have permission`)
|
|
518
542
|
}
|
|
519
543
|
|
|
@@ -549,6 +573,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
549
573
|
if (!iseobj(user)) {
|
|
550
574
|
console.log('token', token)
|
|
551
575
|
console.log('[API]updateAPIs/check user: invalid user')
|
|
576
|
+
console.log(`token does not have permission`)
|
|
552
577
|
return Promise.reject(`token does not have permission`)
|
|
553
578
|
}
|
|
554
579
|
|
|
@@ -587,6 +612,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
587
612
|
if (!iseobj(user)) {
|
|
588
613
|
console.log('token', token)
|
|
589
614
|
console.log('[API]syncAndReplaceApis/check user: invalid user')
|
|
615
|
+
console.log(`token does not have permission`)
|
|
590
616
|
return Promise.reject(`token does not have permission`)
|
|
591
617
|
}
|
|
592
618
|
|
|
@@ -663,7 +689,7 @@ export default WWebApi
|
|
|
663
689
|
<br class="clear">
|
|
664
690
|
|
|
665
691
|
<footer>
|
|
666
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Nov 02 2023
|
|
692
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Nov 02 2023 22:58:48 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
667
693
|
</footer>
|
|
668
694
|
|
|
669
695
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<br class="clear">
|
|
72
72
|
|
|
73
73
|
<footer>
|
|
74
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Nov 02 2023
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Nov 02 2023 22:58:48 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
75
75
|
</footer>
|
|
76
76
|
|
|
77
77
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
<!-- fontawesome -->
|
|
13
13
|
<link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css" rel="stylesheet">
|
|
14
14
|
|
|
15
|
+
<!-- ___pmwapi___ -->
|
|
16
|
+
<script>
|
|
17
|
+
window.___pmwapi___={
|
|
18
|
+
urlRedirect: '{urlRedirect}',
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
15
22
|
</head>
|
|
16
23
|
<body style="font-family:'Microsoft JhengHei','Avenir','Helvetica', 'Arial', 'sans-serif'; padding:0px; margin:0px;">
|
|
17
24
|
<noscript>
|
package/server/WWebApi.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
2
|
import fs from 'fs'
|
|
3
3
|
import get from 'lodash/get'
|
|
4
|
-
// import map from 'lodash/map'
|
|
5
4
|
import each from 'lodash/each'
|
|
6
5
|
import keys from 'lodash/keys'
|
|
7
|
-
// import cloneDeep from 'lodash/cloneDeep'
|
|
8
6
|
import j2o from 'wsemi/src/j2o.mjs'
|
|
9
7
|
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
10
8
|
import isestr from 'wsemi/src/isestr.mjs'
|
|
@@ -20,6 +18,7 @@ import strdelright from 'wsemi/src/strdelright.mjs'
|
|
|
20
18
|
import pm2resolve from 'wsemi/src/pm2resolve.mjs'
|
|
21
19
|
import b642str from 'wsemi/src/b642str.mjs'
|
|
22
20
|
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
21
|
+
import fsIsFile from 'wsemi/src/fsIsFile.mjs'
|
|
23
22
|
import replace from 'wsemi/src/replace.mjs'
|
|
24
23
|
import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
|
|
25
24
|
import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
@@ -44,6 +43,7 @@ import ds from '../src/schema/index.mjs'
|
|
|
44
43
|
* @param {Object} [opt.webDescription={}] 輸入站台描述物件,至少包含語系eng與cht鍵的名稱,預設{}
|
|
45
44
|
* @param {String} [opt.webLogo=''] 輸入站台logo字串,採base64格式,預設''
|
|
46
45
|
* @param {String} [opt.subfolder=''] 輸入站台所在子目錄字串,提供站台位於內網採反向代理進行服務時,故需支援位於子目錄情形,預設''
|
|
46
|
+
* @param {String} [opt.urlRedirect=''] 輸入錯誤時自動轉址字串,提供站台例如無法登入或驗證失敗時須自動轉址,預設''
|
|
47
47
|
* @returns {Object} 回傳物件,其內server為hapi伺服器實體,wsrv為w-converhp的伺服器事件物件,wsds為w-serv-webdata的伺服器事件物件,可監聽error事件
|
|
48
48
|
* @example
|
|
49
49
|
* import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
|
|
@@ -195,6 +195,10 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
|
|
198
|
+
//urlRedirect
|
|
199
|
+
let urlRedirect = get(opt, 'urlRedirect', '')
|
|
200
|
+
|
|
201
|
+
|
|
198
202
|
//WServOrm
|
|
199
203
|
let optWServOrm = {
|
|
200
204
|
bCheckUser,
|
|
@@ -232,7 +236,8 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
232
236
|
|
|
233
237
|
//check
|
|
234
238
|
if (!iseobj(userSelf)) {
|
|
235
|
-
console.log(`
|
|
239
|
+
console.log(`token`, token)
|
|
240
|
+
console.log(`can not find the user from token`)
|
|
236
241
|
return Promise.reject(`can not find the user from token`)
|
|
237
242
|
}
|
|
238
243
|
|
|
@@ -245,6 +250,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
245
250
|
//check
|
|
246
251
|
if (!b) {
|
|
247
252
|
console.log('userSelf', userSelf)
|
|
253
|
+
console.log(`user does not have permission`)
|
|
248
254
|
return Promise.reject(`user does not have permission`)
|
|
249
255
|
}
|
|
250
256
|
|
|
@@ -261,6 +267,8 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
261
267
|
|
|
262
268
|
//parsePayload
|
|
263
269
|
let parsePayload = async (req) => {
|
|
270
|
+
|
|
271
|
+
//inp
|
|
264
272
|
let inp = get(req, 'payload')
|
|
265
273
|
|
|
266
274
|
//to obj
|
|
@@ -271,6 +279,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
271
279
|
//check
|
|
272
280
|
if (!iseobj(inp)) {
|
|
273
281
|
console.log('inp', inp)
|
|
282
|
+
console.log(`invalid inp from req`)
|
|
274
283
|
return Promise.reject(`invalid inp from req`)
|
|
275
284
|
}
|
|
276
285
|
|
|
@@ -281,6 +290,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
281
290
|
if (!isestr(group)) {
|
|
282
291
|
console.log('inp', inp)
|
|
283
292
|
console.log('group', group)
|
|
293
|
+
console.log(`invalid group from inp`)
|
|
284
294
|
return Promise.reject(`invalid group from inp`)
|
|
285
295
|
}
|
|
286
296
|
|
|
@@ -291,6 +301,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
291
301
|
if (!isearr(apis)) {
|
|
292
302
|
console.log('inp', inp)
|
|
293
303
|
console.log('apis', apis)
|
|
304
|
+
console.log(`invalid apis from inp`)
|
|
294
305
|
return Promise.reject(`invalid apis from inp`)
|
|
295
306
|
}
|
|
296
307
|
|
|
@@ -349,6 +360,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
349
360
|
if (!isestr(group)) {
|
|
350
361
|
console.log('params', params)
|
|
351
362
|
console.log('group', group)
|
|
363
|
+
console.log(`invalid group`)
|
|
352
364
|
return Promise.reject(`invalid group`)
|
|
353
365
|
}
|
|
354
366
|
|
|
@@ -360,6 +372,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
360
372
|
if (!isearr(apis)) {
|
|
361
373
|
console.log('params', params)
|
|
362
374
|
console.log('apis', apis)
|
|
375
|
+
console.log(`invalid apis`)
|
|
363
376
|
return Promise.reject(`invalid apis`)
|
|
364
377
|
}
|
|
365
378
|
|
|
@@ -387,9 +400,18 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
387
400
|
let fnEntryOut = 'index.html'
|
|
388
401
|
try {
|
|
389
402
|
let fpEntryIn = path.resolve(pathStaticFiles, fnEntryIn)
|
|
403
|
+
if (!fsIsFile(fpEntryIn)) {
|
|
404
|
+
fpEntryIn = path.resolve(pathStaticFiles, fnEntryOut) //本機開發另使用html替代tmp
|
|
405
|
+
}
|
|
406
|
+
if (!fsIsFile(fpEntryIn)) {
|
|
407
|
+
console.log('fpEntryIn', fpEntryIn)
|
|
408
|
+
throw new Error(`invalid fpEntryIn`)
|
|
409
|
+
}
|
|
390
410
|
let fpEntryOut = path.resolve(pathStaticFiles, fnEntryOut)
|
|
391
411
|
let c = fs.readFileSync(fpEntryIn, 'utf8')
|
|
412
|
+
c = replace(c, '/mapi/', '{sfd}/') //方法同genEntry
|
|
392
413
|
c = replace(c, '{sfd}', subfolder)
|
|
414
|
+
c = replace(c, '{urlRedirect}', urlRedirect)
|
|
393
415
|
fs.writeFileSync(fpEntryOut, c, 'utf8')
|
|
394
416
|
}
|
|
395
417
|
catch (err) {
|
|
@@ -436,6 +458,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
436
458
|
if (!iseobj(user)) {
|
|
437
459
|
console.log('token', token)
|
|
438
460
|
console.log('[API]getUserByToken/check user: invalid user')
|
|
461
|
+
console.log(`token does not have permission`)
|
|
439
462
|
return Promise.reject(`token does not have permission`)
|
|
440
463
|
}
|
|
441
464
|
|
|
@@ -467,6 +490,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
467
490
|
if (!iseobj(user)) {
|
|
468
491
|
console.log('token', token)
|
|
469
492
|
console.log('[API]getAPIsList/check user: invalid user')
|
|
493
|
+
console.log(`token does not have permission`)
|
|
470
494
|
return Promise.reject(`token does not have permission`)
|
|
471
495
|
}
|
|
472
496
|
|
|
@@ -502,6 +526,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
502
526
|
if (!iseobj(user)) {
|
|
503
527
|
console.log('token', token)
|
|
504
528
|
console.log('[API]updateAPIs/check user: invalid user')
|
|
529
|
+
console.log(`token does not have permission`)
|
|
505
530
|
return Promise.reject(`token does not have permission`)
|
|
506
531
|
}
|
|
507
532
|
|
|
@@ -540,6 +565,7 @@ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
|
|
|
540
565
|
if (!iseobj(user)) {
|
|
541
566
|
console.log('token', token)
|
|
542
567
|
console.log('[API]syncAndReplaceApis/check user: invalid user')
|
|
568
|
+
console.log(`token does not have permission`)
|
|
543
569
|
return Promise.reject(`token does not have permission`)
|
|
544
570
|
}
|
|
545
571
|
|
package/src/App.vue
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
<script>
|
|
17
17
|
import get from 'lodash/get'
|
|
18
18
|
import cloneDeep from 'lodash/cloneDeep'
|
|
19
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
20
|
+
import isDev from 'wsemi/src/isDev.mjs'
|
|
19
21
|
import wui from 'w-ui-loginout/src/WUiLoginout.mjs'
|
|
20
22
|
import Layout from './components/Layout.vue'
|
|
21
23
|
import LayoutState from './components/LayoutState.vue'
|
|
@@ -50,12 +52,25 @@ export default {
|
|
|
50
52
|
console.log('login error', cloneDeep(data))
|
|
51
53
|
vo.$ui.updateConnState(data.text)
|
|
52
54
|
vo.$ui.updateUserToken('')
|
|
53
|
-
|
|
55
|
+
let urlRedirect = get(window, '___pmwapi___.urlRedirect', '')
|
|
56
|
+
if (!isestr(urlRedirect)) {
|
|
57
|
+
console.log('urlRedirect', urlRedirect)
|
|
58
|
+
throw new Error(`invalid urlRedirect`)
|
|
59
|
+
}
|
|
60
|
+
if (isDev()) {
|
|
61
|
+
console.log('60s redirect to:', urlRedirect)
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
window.location.href = urlRedirect
|
|
64
|
+
}, 60 * 1000)
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
window.location.href = urlRedirect
|
|
68
|
+
}
|
|
54
69
|
}
|
|
55
70
|
|
|
56
71
|
//login
|
|
57
72
|
console.log('login...')
|
|
58
|
-
let ll = wui('
|
|
73
|
+
let ll = wui('wapi', {
|
|
59
74
|
timeWaitAnimation: 2000,
|
|
60
75
|
params: {},
|
|
61
76
|
})
|
package/src/store/mutations.mjs
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import each from 'lodash/each'
|
|
2
2
|
import set from 'lodash/set'
|
|
3
|
-
import cloneDeep from 'lodash/cloneDeep'
|
|
4
3
|
import * as types from './types.mjs'
|
|
5
4
|
import ds from '../schema/index.mjs'
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
//userDef
|
|
9
|
-
let userDef = {
|
|
10
|
-
id: '', //id-for-admin
|
|
11
|
-
name: '', //測試者
|
|
12
|
-
email: '', //id-for-admin@gmail.com
|
|
13
|
-
// isVirtual: 'n',
|
|
14
|
-
isAdmin: 'n',
|
|
15
|
-
// isActive: 'n',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
7
|
//state, 全域狀態
|
|
19
8
|
let state = {
|
|
20
9
|
|
|
@@ -35,8 +24,12 @@ let state = {
|
|
|
35
24
|
menu: {}, //初始值需為物件, 否則LayoutContent會取menu.key出錯
|
|
36
25
|
|
|
37
26
|
userToken: '',
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
user: {
|
|
28
|
+
id: '', //id-for-admin
|
|
29
|
+
name: '', //測試者
|
|
30
|
+
email: '', //admin@example.com
|
|
31
|
+
isAdmin: 'n',
|
|
32
|
+
},
|
|
40
33
|
|
|
41
34
|
lang: 'cht',
|
|
42
35
|
keyLangs: {
|
package/srv.mjs
CHANGED
|
@@ -16,6 +16,7 @@ let opt = {
|
|
|
16
16
|
|
|
17
17
|
serverPort: 11005,
|
|
18
18
|
subfolder: '', //mapi
|
|
19
|
+
urlRedirect: 'https://www.google.com/', //本機測試時得先編譯, 再瀏覽: http://localhost:11005/
|
|
19
20
|
|
|
20
21
|
webName: {
|
|
21
22
|
'eng': 'API Service',
|
|
@@ -35,7 +36,7 @@ let getUserByToken = (token) => {
|
|
|
35
36
|
return {
|
|
36
37
|
id: 'id-for-application',
|
|
37
38
|
name: 'application',
|
|
38
|
-
email: '
|
|
39
|
+
email: 'application@example.com',
|
|
39
40
|
isAdmin: 'y',
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -53,6 +54,7 @@ let getUserByToken = (token) => {
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
let verifyUser = (user) => {
|
|
57
|
+
// return false //測試無法登入
|
|
56
58
|
console.log('於生產環境時得加入驗證user機制')
|
|
57
59
|
return user.isAdmin === 'y' //測試僅系統管理者使用
|
|
58
60
|
}
|
package/tableTags-web-api.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"apis":"
|
|
1
|
+
{"apis":"4rDZ5D"}
|