w-web-sso 1.0.23 → 1.0.25

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * w-web-sso v1.0.23
2
+ * w-web-sso v1.0.25
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
package/docs/WWebSso.html CHANGED
@@ -387,7 +387,7 @@
387
387
  <br class="clear">
388
388
 
389
389
  <footer>
390
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a> on Wed Jul 23 2025 15:26:00 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
390
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a> on Wed Jul 23 2025 16:44:43 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
391
391
  </footer>
392
392
 
393
393
  <script>prettyPrint();</script>
@@ -1172,7 +1172,7 @@ export default WWebSso
1172
1172
  <br class="clear">
1173
1173
 
1174
1174
  <footer>
1175
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a> on Wed Jul 23 2025 15:26:00 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1175
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a> on Wed Jul 23 2025 16:44:43 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1176
1176
  </footer>
1177
1177
 
1178
1178
  <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.4</a> on Wed Jul 23 2025 15:26:00 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a> on Wed Jul 23 2025 16:44:43 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-web-sso",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "main": "dist/w-web-sso.umd.js",
5
5
  "dependencies": {
6
6
  "@mdi/js": "^7.4.47",
@@ -7,7 +7,7 @@ import ispm from 'wsemi/src/ispm.mjs'
7
7
 
8
8
 
9
9
  async function getUserByToken(url, tokenSelf, tokenTar, opt = {}) {
10
- //url: http://localhost:11007/api/getSsoUserInfor
10
+ //url: http://localhost:11007/api/getSsoUserInfor?token={sysToken}&key=token&value={token}
11
11
  let errTemp = null
12
12
 
13
13
  //check
@@ -25,7 +25,9 @@ async function getUserByToken(url, tokenSelf, tokenTar, opt = {}) {
25
25
  let funConvertUser = get(opt, 'funConvertUser')
26
26
 
27
27
  //url
28
- url = `${url}?token={sysToken}&key=token&value={token}`
28
+ if (url.indexOf('token={sysToken}') < 0 && url.indexOf('key=token') < 0 && url.indexOf('value={token}') < 0) {
29
+ return Promise.reject(`no 'token={sysToken}', 'key=token', 'value={token}' in url`)
30
+ }
29
31
  url = url.replaceAll('{sysToken}', tokenSelf) //系統介接用ssoToken
30
32
  url = url.replaceAll('{token}', tokenTar)
31
33
  // console.log('getUserByToken: url', url)
@@ -0,0 +1,100 @@
1
+ import axios from 'axios'
2
+ import get from 'lodash-es/get.js'
3
+ import isestr from 'wsemi/src/isestr.mjs'
4
+ import iseobj from 'wsemi/src/iseobj.mjs'
5
+ import isfun from 'wsemi/src/isfun.mjs'
6
+ import ispm from 'wsemi/src/ispm.mjs'
7
+
8
+
9
+ async function getUserByUserId(url, tokenSelf, userIdTar, opt = {}) {
10
+ //url: http://localhost:11007/api/getSsoUserInfor?token={sysToken}&key=userId&value={userId}
11
+ let errTemp = null
12
+
13
+ //check
14
+ if (!isestr(url)) {
15
+ return Promise.reject('invalid url')
16
+ }
17
+ if (!isestr(tokenSelf)) {
18
+ return Promise.reject('invalid tokenSelf')
19
+ }
20
+ if (!isestr(userIdTar)) {
21
+ return Promise.reject('invalid userIdTar')
22
+ }
23
+
24
+ //funConvertUser
25
+ let funConvertUser = get(opt, 'funConvertUser')
26
+
27
+ //url
28
+ if (url.indexOf('token={sysToken}') < 0 && url.indexOf('key=userId') < 0 && url.indexOf('value={userId}') < 0) {
29
+ return Promise.reject(`no 'token={sysToken}', 'key=userId', 'value={userId}' in url`)
30
+ }
31
+ url = url.replaceAll('{sysToken}', tokenSelf) //系統介接用ssoToken
32
+ url = url.replaceAll('{userId}', userIdTar)
33
+ // console.log('getUserByUserId: url', url)
34
+
35
+ //get
36
+ let res = await axios.get(url)
37
+ .catch((err) => {
38
+ errTemp = err.toString()
39
+ })
40
+
41
+ //check
42
+ if (errTemp !== null) {
43
+ console.log('res', res)
44
+ console.log('errTemp', errTemp)
45
+ console.log(`can not get user by url[${url}]`)
46
+ return Promise.reject(`can not get user by url[${url}]`) //由SSO取得使用者資訊錯誤
47
+ }
48
+
49
+ //data
50
+ let data = get(res, 'data')
51
+
52
+ //state
53
+ let state = get(data, 'state', '')
54
+
55
+ //msg
56
+ let msg = get(data, 'msg')
57
+
58
+ //check
59
+ if (state !== 'success') {
60
+ console.log('res', res)
61
+ console.log('data', data)
62
+ console.log('state', state)
63
+ console.log('errTemp', msg)
64
+ console.log(`can not get user data by url[${url}]`)
65
+ return Promise.reject(`can not get user data by url[${url}]`) //取得使用者資訊失敗
66
+ }
67
+
68
+ //u
69
+ let u = msg
70
+ // console.log('getUserByUserId u(msg)', u)
71
+
72
+ //check
73
+ if (!iseobj(u)) {
74
+ console.log(`no user data by url[${url}]`)
75
+ return Promise.reject(`no user data by url[${url}]`)
76
+ }
77
+
78
+ //check
79
+ if (isfun(funConvertUser)) {
80
+
81
+ //funConvertUser
82
+ u = funConvertUser(u)
83
+ if (ispm(u)) {
84
+ u = await u
85
+ }
86
+ // console.log('getUserByUserId u(funConvertUser)', u)
87
+
88
+ //check
89
+ if (!iseobj(u)) {
90
+ console.log(`no user data after funConvertUser`)
91
+ return Promise.reject(`no user data after funConvertUser`)
92
+ }
93
+
94
+ }
95
+
96
+ return u
97
+ }
98
+
99
+
100
+ export default getUserByUserId
@@ -9,7 +9,7 @@ import pmSeries from 'wsemi/src/pmSeries.mjs'
9
9
 
10
10
 
11
11
  async function getUsersByToken(url, tokenSelf, opt = {}) {
12
- //url: http://localhost:11007/api/getSsoUsersList
12
+ //url: http://localhost:11007/api/getSsoUsersList?token={sysToken}
13
13
  let errTemp = null
14
14
 
15
15
  //check
@@ -24,7 +24,9 @@ async function getUsersByToken(url, tokenSelf, opt = {}) {
24
24
  let funConvertUser = get(opt, 'funConvertUser')
25
25
 
26
26
  //url
27
- url = `${url}?token={sysToken}`
27
+ if (url.indexOf('token={sysToken}') < 0) {
28
+ return Promise.reject(`no 'token={sysToken}' in url`)
29
+ }
28
30
  url = url.replaceAll('{sysToken}', tokenSelf) //系統介接用ssoToken
29
31
  // console.log('getUsersByToken: url', url)
30
32