w-web-sso 1.0.0

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.
Files changed (102) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.github/workflows/ci-test.yml +24 -0
  5. package/.jsdoc +25 -0
  6. package/.vscode/launch.json +20 -0
  7. package/LICENSE +21 -0
  8. package/README.md +25 -0
  9. package/SECURITY.md +5 -0
  10. package/babel.config.js +15 -0
  11. package/dist/css/app.969ad1db.css +1 -0
  12. package/dist/index.tmp +3 -0
  13. package/dist/js/app-legacy.ff64be1c.js +2 -0
  14. package/dist/js/app-legacy.ff64be1c.js.map +1 -0
  15. package/dist/js/app.ff64be1c.js +2 -0
  16. package/dist/js/app.ff64be1c.js.map +1 -0
  17. package/dist/js/chunk-vendors-legacy.0bb7a31b.js +13 -0
  18. package/dist/js/chunk-vendors-legacy.0bb7a31b.js.map +1 -0
  19. package/dist/js/chunk-vendors.0bb7a31b.js +13 -0
  20. package/dist/js/chunk-vendors.0bb7a31b.js.map +1 -0
  21. package/dist/w-web-sso.umd.js +7 -0
  22. package/dist/w-web-sso.umd.js.map +1 -0
  23. package/docs/WWebSso.html +938 -0
  24. package/docs/WWebSso.mjs.html +721 -0
  25. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  26. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  27. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  28. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  29. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  30. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  31. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  33. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  35. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  36. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  37. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  38. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  43. package/docs/index.html +84 -0
  44. package/docs/scripts/collapse.js +39 -0
  45. package/docs/scripts/commonNav.js +28 -0
  46. package/docs/scripts/linenumber.js +25 -0
  47. package/docs/scripts/nav.js +12 -0
  48. package/docs/scripts/polyfill.js +4 -0
  49. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  50. package/docs/scripts/prettify/lang-css.js +2 -0
  51. package/docs/scripts/prettify/prettify.js +28 -0
  52. package/docs/scripts/search.js +99 -0
  53. package/docs/styles/jsdoc.css +776 -0
  54. package/docs/styles/prettify.css +80 -0
  55. package/g.backupDb.mjs +10 -0
  56. package/g.getSettings.mjs +17 -0
  57. package/g.initialData.mjs +94 -0
  58. package/g.initialTestData.mjs +21 -0
  59. package/g.mOrm.mjs +24 -0
  60. package/g.provideUsers.mjs +45 -0
  61. package/package.json +70 -0
  62. package/public/index.html +30 -0
  63. package/script.txt +22 -0
  64. package/server/WWebSso.mjs +649 -0
  65. package/server/hashPassword.mjs +27 -0
  66. package/server/proc.mjs +543 -0
  67. package/server/provideUsers.mjs +68 -0
  68. package/src/App.vue +123 -0
  69. package/src/components/Common/CheckYes.vue +85 -0
  70. package/src/components/Common/CheckYesNo.vue +91 -0
  71. package/src/components/Common/LabelItem.vue +106 -0
  72. package/src/components/Common/LoadingWinBar.vue +115 -0
  73. package/src/components/Layout.vue +160 -0
  74. package/src/components/LayoutContent.vue +193 -0
  75. package/src/components/LayoutContentUsers.vue +498 -0
  76. package/src/components/LayoutState.vue +91 -0
  77. package/src/components/PageLogin.vue +524 -0
  78. package/src/components/VeUser.vue +446 -0
  79. package/src/components/ruleGroup.vue +645 -0
  80. package/src/main.js +97 -0
  81. package/src/plugins/mDataSelectorSchema.mjs +30 -0
  82. package/src/plugins/mDataSupport.mjs +23 -0
  83. package/src/plugins/mShare.mjs +229 -0
  84. package/src/plugins/mUI.mjs +229 -0
  85. package/src/schema/gi.mjs +8 -0
  86. package/src/schema/index.mjs +18 -0
  87. package/src/schema/tables/tokens.mjs +70 -0
  88. package/src/schema/tables/users.mjs +110 -0
  89. package/src/store/actions.mjs +1 -0
  90. package/src/store/getters.mjs +1 -0
  91. package/src/store/index.mjs +25 -0
  92. package/src/store/mutations.mjs +333 -0
  93. package/src/store/types.mjs +15 -0
  94. package/srv.mjs +84 -0
  95. package/tableTags-web-sso.json +1 -0
  96. package/test/all.test.mjs +10 -0
  97. package/toolg/addVersion.mjs +4 -0
  98. package/toolg/cleanFolder.mjs +4 -0
  99. package/toolg/gDistRollup.mjs +36 -0
  100. package/toolg/genEntry.mjs +23 -0
  101. package/toolg/modifyReadme.mjs +4 -0
  102. package/vue.config.js +15 -0
@@ -0,0 +1,446 @@
1
+ <template>
2
+ <WDialog
3
+ :show.sync="bShow"
4
+ :icon="mdiAccountEdit"
5
+ _maxWidth="1200"
6
+ _minWidth="1200"
7
+ :fullscreen="true"
8
+ :title="$t('editUser')"
9
+ :save-btn-tooltip="$t('save')"
10
+ :close-btn-tooltip="$t('close')"
11
+ @click-save="clickSave"
12
+ @click-close="clickClose"
13
+ @resize="resize"
14
+ >
15
+ <template v-slot:content>
16
+ <div style="min-height:400px;">
17
+
18
+ <div style="padding-top:20px;"></div>
19
+
20
+ <div style="padding:0px 20px 20px 20px; display:flex; align-items:center;">
21
+
22
+ <div style="padding-right:10px; color:#777; white-space:nowrap;">{{$t('username')}}:</div>
23
+
24
+ <WText
25
+ style="width:100%;"
26
+ v-model="u.name"
27
+ ></WText>
28
+
29
+ </div>
30
+
31
+ <div style="padding:0px 20px 20px 20px; display:flex; align-items:center;">
32
+
33
+ <div style="padding-right:10px; color:#777; white-space:nowrap;">{{$t('email')}}:</div>
34
+
35
+ <WText
36
+ style="width:100%;"
37
+ v-model="u.email"
38
+ ></WText>
39
+
40
+ </div>
41
+
42
+ <div style="padding:0px 20px 20px 20px; display:flex; align-items:center;">
43
+
44
+ <div style="padding-right:10px; color:#777; white-space:nowrap;">{{$t('from')}}:</div>
45
+
46
+ <WTextSuggest
47
+ style="width:200px;"
48
+ :noResultsText="'無'"
49
+ :items="userFroms"
50
+ v-model="u.from"
51
+ ></WTextSuggest>
52
+
53
+ </div>
54
+
55
+ <div style="padding-top:20px; border-top:1px solid #ddd;"></div>
56
+
57
+ <div style="padding:0px 20px 20px 20px;">
58
+
59
+ <div style="padding-bottom:5px; color:#777; white-space:nowrap;">{{$t('belongToPermissionGroup')}}:</div>
60
+
61
+ <div
62
+ style="display:inline-block; padding:0px 15px 15px 0px;"
63
+ :key="kg"
64
+ v-for="(g,kg) in groups"
65
+ >
66
+
67
+ <div style="padding:3px 15px 3px 0px; _border-radius:30px; _border:1px dashed #aaa; display:flex; align-content:center;">
68
+
69
+ <WCheckbox
70
+ :value="kpugs[g.id]"
71
+ _checkedIconColor="'rgba(200,70,20,0.8)'"
72
+ _uncheckedIconColor="'rgba(200,70,20,0.8)'"
73
+ @input="(v)=>{modifyUserRuleGroupsIds(g.id,v)}"
74
+ ></WCheckbox>
75
+
76
+ <div>
77
+ {{g.name}}
78
+ </div>
79
+
80
+ </div>
81
+
82
+ </div>
83
+
84
+ <div style="padding-bottom:5px; color:#777; white-space:nowrap;">{{$t('availableTarget')}}:</div>
85
+
86
+ <div style="border:1px dashed #f26; background:rgba(255,50,100,0.05);">
87
+
88
+ <ruleGroup
89
+ :height="600"
90
+ :group="mergedGroup"
91
+ :showHead="false"
92
+ :editable="false"
93
+ ></ruleGroup>
94
+
95
+ </div>
96
+
97
+ </div>
98
+
99
+ <div style="padding-top:20px; border-top:1px solid #ddd;"></div>
100
+
101
+ <div style="padding:0px 20px 20px 20px; display:flex; align-items:center;">
102
+
103
+ <div style="padding-right:10px; color:#777; white-space:nowrap;">{{$t('isAManager')}}:</div>
104
+
105
+ <WSwitch
106
+ :value="u.isAdmin==='y'"
107
+ @input="(v)=>{u.isAdmin=v?'y':'n'}"
108
+ ></WSwitch>
109
+
110
+ </div>
111
+
112
+ <div style="padding:0px 20px 20px 20px; display:flex; align-items:center;">
113
+
114
+ <div style="padding-right:10px; color:#777; white-space:nowrap;">{{$t('isActive')}}:</div>
115
+
116
+ <WSwitch
117
+ :value="u.isActive==='y'"
118
+ @input="(v)=>{u.isActive=v?'y':'n'}"
119
+ ></WSwitch>
120
+
121
+ </div>
122
+
123
+ <div style="padding-top:20px; border-top:1px solid #ddd;"></div>
124
+
125
+ <div style="padding:0px 20px 20px 20px; display:flex; align-items:center;">
126
+
127
+ <div style="padding-right:10px; color:#777; white-space:nowrap;">{{$t('remark')}}:</div>
128
+
129
+ <WText
130
+ style="width:100%;"
131
+ v-model="u.description"
132
+ ></WText>
133
+
134
+ </div>
135
+
136
+ <div style="padding-top:20px; border-top:1px solid #ddd;"></div>
137
+
138
+ <div style="padding:0px 20px 20px 20px; display:flex; align-items:center;">
139
+
140
+ <div style="padding-right:10px; color:#777; white-space:nowrap;">{{$t('dayCreate')}}:</div>
141
+
142
+ <div style="padding:0px 7px; border-radius:20px; font-size:0.8rem; color:#fff; background:#A1887F;">
143
+ {{getCreateDay(u)}}
144
+ </div>
145
+
146
+ </div>
147
+
148
+ </div>
149
+ </template>
150
+ </WDialog>
151
+ </template>
152
+
153
+ <script>
154
+ import { mdiAccountEdit, mdiFileTree } from '@mdi/js/mdi.js'
155
+ import Vue from 'vue'
156
+ // import JSON5 from 'json5'
157
+ import get from 'lodash-es/get.js'
158
+ import each from 'lodash-es/each.js'
159
+ import map from 'lodash-es/map.js'
160
+ import trim from 'lodash-es/trim.js'
161
+ import uniq from 'lodash-es/uniq.js'
162
+ import filter from 'lodash-es/filter.js'
163
+ import join from 'lodash-es/join.js'
164
+ import sortBy from 'lodash-es/sortBy.js'
165
+ import cloneDeep from 'lodash-es/cloneDeep.js'
166
+ import genPm from 'wsemi/src/genPm.mjs'
167
+ import sep from 'wsemi/src/sep.mjs'
168
+ import timemsTZ2day from 'wsemi/src/timemsTZ2day.mjs'
169
+ import isernot from 'wsemi/src/isernot.mjs'
170
+ import isestr from 'wsemi/src/isestr.mjs'
171
+ import WDialog from 'w-component-vue/src/components/WDialog.vue'
172
+ import WText from 'w-component-vue/src/components/WText.vue'
173
+ import WTextSuggest from 'w-component-vue/src/components/WTextSuggest.vue'
174
+ import WSwitch from 'w-component-vue/src/components/WSwitch.vue'
175
+ import WCheckbox from 'w-component-vue/src/components/WCheckbox.vue'
176
+ import { getUserRules } from '../plugins/mShare.mjs'
177
+ import ruleGroup from './ruleGroup.vue'
178
+
179
+
180
+ export default {
181
+ components: {
182
+ WDialog,
183
+ WText,
184
+ WTextSuggest,
185
+ WSwitch,
186
+ WCheckbox,
187
+ ruleGroup,
188
+ },
189
+ props: {
190
+ },
191
+ data: function() {
192
+ return {
193
+ mdiAccountEdit,
194
+ mdiFileTree,
195
+
196
+ bShow: false,
197
+ pm: null,
198
+
199
+ // panelHeight: 100,
200
+
201
+ u: null,
202
+ kpugs: {},
203
+ mergedGroup: {},
204
+
205
+ }
206
+ },
207
+ mounted: function() {
208
+ //console.log('mounted')
209
+
210
+ let vo = this
211
+
212
+ //set
213
+ Vue.prototype.$dg.showVeUser = vo.show
214
+
215
+ },
216
+ computed: {
217
+
218
+ targets: function() {
219
+ return get(this, `$store.state.targets`)
220
+ },
221
+
222
+ ruleGroups: function() {
223
+ return get(this, `$store.state.ruleGroups`)
224
+ },
225
+
226
+ groups: function() {
227
+ // console.log('computed groups')
228
+
229
+ let vo = this
230
+
231
+ //rs
232
+ let rs = map(vo.ruleGroups, (v) => {
233
+ // let rules = JSON5.parse(v.crules)
234
+ return {
235
+ ...v,
236
+ // rules,
237
+ }
238
+ })
239
+
240
+ //sortBy
241
+ rs = sortBy(rs, 'order')
242
+
243
+ return rs
244
+ },
245
+
246
+ users: function() {
247
+ return get(this, `$store.state.users`)
248
+ },
249
+
250
+ userFroms: function() {
251
+ let vo = this
252
+ let froms = map(vo.users, 'from')
253
+ froms = uniq(froms)
254
+ froms = filter(froms, isernot)
255
+ froms = sortBy(froms)
256
+ return froms
257
+ },
258
+
259
+ },
260
+ methods: {
261
+
262
+ resize: function(msg) {
263
+ // console.log('methods resize', msg)
264
+
265
+ // let vo = this
266
+
267
+ // //panelHeight
268
+ // vo.panelHeight = msg.contentHeightMax - 59 //- 61.6
269
+
270
+ },
271
+
272
+ getCreateDay: function(u) {
273
+ let timeCreate = get(u, 'timeCreate', '')
274
+ return timemsTZ2day(timeCreate)
275
+ },
276
+
277
+ modifyUserRuleGroupsIds: function(ruleGroupsId, b) {
278
+ // console.log('methods modifyUserRuleGroupsIds', ruleGroupsId, b)
279
+
280
+ let vo = this
281
+
282
+ //kpugs, 因kugs初始化可能不是全部群組, 得用set才能觸發所有checkbox的value記憶體變更
283
+ // vo.kpugs[ruleGroupsId] = b
284
+ vo.$set(vo.kpugs, ruleGroupsId, b)
285
+
286
+ //modify ruleGroupsIds
287
+ let ruleGroupsIds = []
288
+ each(vo.kpugs, (v, k) => {
289
+ if (v) {
290
+ ruleGroupsIds.push(k)
291
+ }
292
+ })
293
+ ruleGroupsIds = join(ruleGroupsIds, ';')
294
+ vo.u.ruleGroupsIds = ruleGroupsIds
295
+ // console.log('ruleGroupsIds', ruleGroupsIds)
296
+
297
+ //calcMergedGroup
298
+ vo.calcMergedGroup()
299
+
300
+ },
301
+
302
+ calcMergedGroup: function() {
303
+ let vo = this
304
+
305
+ //save
306
+ let u = cloneDeep(vo.u)
307
+
308
+ //getUserRules
309
+ let urs = getUserRules(u, vo.ruleGroups, vo.targets)
310
+ // console.log('urs', urs)
311
+
312
+ //mergedGroup
313
+ let mergedGroup = {
314
+ id: 'merged-group',
315
+ name: urs.ruleGroupsNames,
316
+ crules: JSON.stringify(urs.rules),
317
+ }
318
+
319
+ //mergedGroup
320
+ vo.mergedGroup = mergedGroup
321
+
322
+ },
323
+
324
+ clickSave: function(msg) {
325
+ //console.log('methods clickSave', msg)
326
+
327
+ let vo = this
328
+
329
+ async function core() {
330
+ let errTemp = null
331
+
332
+ //check
333
+ if (!isestr(vo.u.name)) {
334
+ vo.$alert(vo.$t('isUsernameEmpty'), { type: 'error' })
335
+ return
336
+ }
337
+
338
+ //show loading
339
+ vo.$ui.updateLoading(true)
340
+
341
+ //u
342
+ let u = {
343
+ id: vo.u.id,
344
+ name: trim(vo.u.name),
345
+ email: trim(vo.u.email),
346
+ description: trim(vo.u.description),
347
+ ruleGroupsIds: trim(vo.u.ruleGroupsIds),
348
+ from: trim(vo.u.from),
349
+ isAdmin: vo.u.isAdmin,
350
+ isActive: vo.u.isActive,
351
+ // userId, //insert時自動由後端給予
352
+ // timeCreate, //insert時自動由後端給予
353
+ // userIdUpdate: userId, //虛擬使用者皆與創建者相同
354
+ // timeUpdate: timeCreate,
355
+ }
356
+
357
+ //save
358
+ await vo.$fapi.users.save(u)
359
+ .catch((err) => {
360
+ errTemp = err
361
+ })
362
+
363
+ //check
364
+ if (errTemp !== null) {
365
+ vo.$alert(`${vo.$t('failedToSaveUser')}: ${errTemp}`, { type: 'error' })
366
+ return
367
+ }
368
+
369
+ //alert
370
+ vo.$alert(vo.$t('successfulToSaveUser'))
371
+
372
+ }
373
+
374
+ //core
375
+ core()
376
+ .then(() => {
377
+
378
+ //resolve
379
+ vo.pm.resolve()
380
+
381
+ //hide
382
+ vo.bShow = false
383
+
384
+ })
385
+ .catch(() => { })
386
+ .finally(() => {
387
+
388
+ //save按鈕解除loading
389
+ msg.pm.resolve()
390
+
391
+ //hide loading
392
+ vo.$ui.updateLoading(false)
393
+
394
+ })
395
+
396
+ },
397
+
398
+ clickClose: function() {
399
+ //console.log('methods clickClose')
400
+
401
+ let vo = this
402
+
403
+ //reject
404
+ vo.pm.reject('close window')
405
+
406
+ //hide
407
+ vo.bShow = false
408
+
409
+ },
410
+
411
+ show: function (u) {
412
+ // console.log('methods show', u)
413
+
414
+ let vo = this
415
+
416
+ //pm
417
+ vo.pm = genPm()
418
+
419
+ //save u
420
+ u = cloneDeep(u)
421
+ vo.u = u
422
+
423
+ //save kpugs
424
+ let kpugs = {}
425
+ let ruleGroupsIds = get(u, 'ruleGroupsIds', '')
426
+ let s = sep(ruleGroupsIds, ';')
427
+ each(s, (v) => {
428
+ kpugs[v] = true
429
+ })
430
+ vo.kpugs = kpugs
431
+
432
+ //calcMergedGroup
433
+ vo.calcMergedGroup()
434
+
435
+ //bShow
436
+ vo.bShow = true
437
+
438
+ return vo.pm
439
+ },
440
+
441
+ }
442
+ }
443
+ </script>
444
+
445
+ <style scoped>
446
+ </style>