w-web-perm 1.0.6 → 1.0.8

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.
@@ -64,7 +64,7 @@
64
64
 
65
65
 
66
66
 
67
- <h4 class="name" id="WWebPerm"><span class="type-signature"></span>new WWebPerm<span class="signature">(WOrm, url, db, getUserByToken, verifyUser, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
67
+ <h4 class="name" id="WWebPerm"><span class="type-signature"></span>new WWebPerm<span class="signature">(WOrm, url, db, getUserByToken, verifyBrowserUser, verifyAppUser, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
68
68
 
69
69
 
70
70
 
@@ -80,7 +80,7 @@
80
80
 
81
81
  <dt class="tag-source">Source:</dt>
82
82
  <dd class="tag-source"><ul class="dummy"><li>
83
- <a href="WWebPerm.mjs.html">WWebPerm.mjs</a>, <a href="WWebPerm.mjs.html#line113">line 113</a>
83
+ <a href="WWebPerm.mjs.html">WWebPerm.mjs</a>, <a href="WWebPerm.mjs.html#line128">line 128</a>
84
84
  </li></ul></dd>
85
85
 
86
86
 
@@ -127,7 +127,7 @@
127
127
 
128
128
  <h5 class="h5-examples">Example</h5>
129
129
 
130
- <pre class="prettyprint"><code>import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
131
130
  bCheckUser: false,
132
131
  getUserById: null,
133
132
  bExcludeWhenNotAdmin: false,
134
133
  serverPort: 11006,
135
134
  subfolder: '', //mperm
136
135
  webName: {
137
136
  'eng': 'Permission Service',
138
137
  'cht': '權限管理系統',
139
138
  },
140
139
  webDescription: {
141
140
  'eng': 'A web service package for user permissions and management targets.',
142
141
  'cht': 'A web service package for user permissions and management targets.',
143
142
  },
144
143
  webLogo: 'data:image/svg+xml;base64,...',
145
144
  // return {} //測試無法登入
146
145
  if (token === '{token-for-application}') { //提供外部應用系統作為存取使用者
147
146
  return {
148
147
  id: 'id-for-application',
149
148
  name: 'application',
150
149
  email: 'admin@example.com',
151
150
  isAdmin: 'y',
152
151
  }
153
152
  }
154
153
  if (token === 'sys') { //開發階段w-ui-loginout自動給予browser使用者(且位於localhost)的token為sys
155
154
  return {
156
155
  id: 'id-for-admin',
157
156
  name: 'tester',
158
157
  email: 'admin@example.com',
159
158
  isAdmin: 'y',
160
159
  }
161
160
  }
162
161
  console.log('invalid token', token)
163
162
  console.log('於生產環境時得加入SSO等驗證token機制')
164
163
  return {}
165
164
  console.log('於生產環境時得加入驗證user機制')
166
165
  return user.isAdmin === 'y' //測試僅系統管理者使用
167
166
  console.log(err)
167
+ <pre class="prettyprint"><code>import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
168
168
  bCheckUser: false,
169
169
  getUserById: null,
170
170
  bExcludeWhenNotAdmin: false,
171
171
  serverPort: 11006,
172
172
  subfolder: '', //mperm
173
173
  urlRedirect: 'https://www.google.com/', //本機測試時得先編譯, 再瀏覽: http://localhost:11006/
174
174
  webName: {
175
175
  'eng': 'Permission Service',
176
176
  'cht': '權限管理系統',
177
177
  },
178
178
  webDescription: {
179
179
  'eng': 'A web service package for user permissions and management targets.',
180
180
  'cht': 'A web service package for user permissions and management targets.',
181
181
  },
182
182
  webLogo: 'data:image/svg+xml;base64,...',
183
183
  // return {} //測試無法登入
184
184
  if (token === '{token-for-application}') { //提供外部應用系統作為存取使用者
185
185
  return {
186
186
  id: 'id-for-application',
187
187
  name: 'application',
188
188
  email: 'application@example.com',
189
189
  isAdmin: 'y',
190
190
  }
191
191
  }
192
192
  if (token === 'sys') { //開發階段w-ui-loginout自動給予browser使用者(且位於localhost)的token為sys
193
193
  return {
194
194
  id: 'id-for-admin',
195
195
  name: 'tester',
196
196
  email: 'admin@example.com', //mappingBy為email, 開發階段時會使用email找到所建置之使用者資料
197
197
  isAdmin: 'y',
198
198
  }
199
199
  }
200
200
  console.log('invalid token', token)
201
201
  console.log('於生產環境時得加入SSO等驗證token機制')
202
202
  return {}
203
203
  console.log('verifyBrowserUser/user', user)
204
204
  // return false //測試無法登入
205
205
  console.log('於生產環境時得加入限制瀏覽器使用者身份機制')
206
206
  return user.isAdmin === 'y' //測試僅系統管理者使用
207
207
  console.log('verifyAppUser/user', user)
208
208
  // return false //測試無法登入
209
209
  console.log('於生產環境時得加入限制應用程式使用者身份機制')
210
210
  return user.isAdmin === 'y' //測試僅系統管理者使用
211
211
  console.log(err)
212
212
 
213
213
 
214
214
 
@@ -305,7 +305,7 @@
305
305
 
306
306
  <tr>
307
307
 
308
- <td class="name"><code>verifyUser</code></td>
308
+ <td class="name"><code>verifyBrowserUser</code></td>
309
309
 
310
310
 
311
311
  <td class="type">
@@ -334,7 +334,43 @@
334
334
  </td>
335
335
 
336
336
 
337
- <td class="description last"><p>輸入處理函數,函數會傳入使用者資訊物件,通過此函數識別後回傳布林值,允許使用者回傳true,反之回傳false</p></td>
337
+ <td class="description last"><p>輸入驗證瀏覽使用者身份之處理函數,函數會傳入使用者資訊物件,通過此函數識別後回傳布林值,允許使用者回傳true,反之回傳false</p></td>
338
+ </tr>
339
+
340
+
341
+
342
+ <tr>
343
+
344
+ <td class="name"><code>verifyAppUser</code></td>
345
+
346
+
347
+ <td class="type">
348
+
349
+
350
+ <span class="param-type">function</span>
351
+
352
+
353
+
354
+
355
+ </td>
356
+
357
+
358
+ <td class="attributes">
359
+
360
+
361
+
362
+
363
+
364
+ </td>
365
+
366
+
367
+
368
+ <td class="default">
369
+
370
+ </td>
371
+
372
+
373
+ <td class="description last"><p>輸入驗證應用程序使用者身份之處理函數,函數會傳入使用者資訊物件,通過此函數識別後回傳布林值,允許使用者回傳true,反之回傳false</p></td>
338
374
  </tr>
339
375
 
340
376
 
@@ -722,6 +758,46 @@
722
758
 
723
759
 
724
760
 
761
+ <tr>
762
+
763
+ <td class="name"><code>urlRedirect</code></td>
764
+
765
+
766
+ <td class="type">
767
+
768
+
769
+ <span class="param-type">String</span>
770
+
771
+
772
+
773
+
774
+ </td>
775
+
776
+
777
+ <td class="attributes">
778
+
779
+ &lt;optional><br>
780
+
781
+
782
+
783
+
784
+
785
+ </td>
786
+
787
+
788
+
789
+ <td class="default">
790
+
791
+ <code>''</code>
792
+
793
+ </td>
794
+
795
+
796
+ <td class="description last"><p>輸入錯誤時自動轉址字串,提供站台例如無法登入或驗證失敗時須自動轉址,預設''</p></td>
797
+ </tr>
798
+
799
+
800
+
725
801
  <tr>
726
802
 
727
803
  <td class="name"><code>mappingBy</code></td>
@@ -849,7 +925,7 @@
849
925
  <br class="clear">
850
926
 
851
927
  <footer>
852
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Nov 02 2023 11:12:12 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
928
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Fri Nov 03 2023 12:07:17 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
853
929
  </footer>
854
930
 
855
931
  <script>prettyPrint();</script>