ts-glitter 20.5.0 → 20.5.2

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 (47) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/cms-plugin/member-setting.js +2 -4
  4. package/lowcode/cms-plugin/member-setting.ts +2 -4
  5. package/lowcode/cms-plugin/shopping-collections.js +2 -2
  6. package/lowcode/cms-plugin/shopping-collections.ts +3 -2
  7. package/lowcode/cms-plugin/shopping-order-manager.js +1 -1
  8. package/lowcode/cms-plugin/shopping-order-manager.ts +1 -1
  9. package/lowcode/cms-plugin/stock-history.js +7 -2
  10. package/lowcode/cms-plugin/stock-history.ts +5 -2
  11. package/lowcode/cms-plugin/user-list.js +98 -97
  12. package/lowcode/cms-plugin/user-list.ts +111 -103
  13. package/lowcode/modules/checkInput.js +1 -1
  14. package/lowcode/modules/checkInput.ts +58 -60
  15. package/lowcode/public-components/checkout/index.js +0 -12
  16. package/lowcode/public-components/checkout/index.ts +1 -12
  17. package/lowcode/public-components/user-manager/um-info.js +49 -48
  18. package/lowcode/public-components/user-manager/um-info.ts +219 -204
  19. package/lowcode/public-components/user-manager/um-order.js +36 -22
  20. package/lowcode/public-components/user-manager/um-order.ts +43 -24
  21. package/lowcode/src/glitterBundle/module/Animation.js +7 -13
  22. package/lowcode/src/glitterBundle/module/Enum.js +2 -6
  23. package/lowcode/src/glitterBundle/module/Html_generate.js +50 -42
  24. package/lowcode/src/glitterBundle/module/PageManager.js +23 -30
  25. package/lowcode/src/glitterBundle/plugins/click-event.js +25 -19
  26. package/lowcode/src/glitterBundle/plugins/dialog-style-editor.js +13 -16
  27. package/lowcode/src/glitterBundle/plugins/editor-elem.js +1 -6
  28. package/lowcode/src/glitterBundle/plugins/editor.js +1 -5
  29. package/lowcode/src/glitterBundle/plugins/html-render.js +2 -5
  30. package/lowcode/src/glitterBundle/plugins/plugin-creater.js +28 -22
  31. package/lowcode/src/glitterBundle/plugins/seo-manager.js +1 -5
  32. package/lowcode/src/glitterBundle/plugins/style-attr.js +1 -5
  33. package/lowcode/src/glitterBundle/plugins/style-editor.js +1 -3
  34. package/package.json +1 -1
  35. package/src/api-public/services/financial-service.js +7 -6
  36. package/src/api-public/services/financial-service.js.map +1 -1
  37. package/src/api-public/services/financial-service.ts +11 -8
  38. package/src/api-public/services/model/handlePaymentTransaction.js +29 -2
  39. package/src/api-public/services/model/handlePaymentTransaction.js.map +1 -1
  40. package/src/api-public/services/model/handlePaymentTransaction.ts +8 -9
  41. package/src/api-public/services/shopping.d.ts +1 -1
  42. package/src/api-public/services/shopping.js +23 -10
  43. package/src/api-public/services/shopping.js.map +1 -1
  44. package/src/api-public/services/shopping.ts +15 -3
  45. package/src/api-public/services/user.js +44 -61
  46. package/src/api-public/services/user.js.map +1 -1
  47. package/src/api-public/services/user.ts +56 -66
@@ -837,9 +837,7 @@ export class User {
837
837
  if (type === 'userID') {
838
838
  query2.push(`userID=${db.escape(query)}`);
839
839
  } else if (type === 'email_or_phone') {
840
- query2.push(
841
- `((email=${db.escape(query)}) or (phone=${db.escape(query)}))`
842
- );
840
+ query2.push(`((email=${db.escape(query)}) or (phone=${db.escape(query)}))`);
843
841
  } else {
844
842
  query2.push(`email=${db.escape(query)}`);
845
843
  }
@@ -2178,100 +2176,98 @@ export class User {
2178
2176
  }
2179
2177
 
2180
2178
  public async updateUserData(userID: string, par: any, manager: boolean = false) {
2181
- const userData = await (async () => {
2182
- const getUser = await db.query(
2183
- `select *
2184
- from \`${this.app}\`.\`t_user\`
2185
- where userID = ${db.escape(userID)}
2179
+ const getUser = await db.query(
2180
+ `SELECT * FROM \`${this.app}\`.t_user WHERE userID = ${db.escape(userID)}
2186
2181
  `,
2187
- []
2188
- );
2189
- return getUser[0] ?? {};
2190
- })();
2182
+ []
2183
+ );
2184
+ const userData = getUser[0] ?? {};
2191
2185
 
2192
- try {
2193
- if (!userData.userData) {
2194
- return { data: {} };
2195
- }
2186
+ if (!userData.userData) {
2187
+ return { data: {} };
2188
+ }
2196
2189
 
2197
- const login_config = await this.getConfigV2({
2198
- key: 'login_config',
2199
- user_id: 'manager',
2200
- });
2201
- const register_form = await this.getConfigV2({
2202
- key: 'custom_form_register',
2203
- user_id: 'manager',
2204
- });
2190
+ try {
2191
+ const login_config = await this.getConfigV2({ key: 'login_config', user_id: 'manager' });
2192
+ const register_form = await this.getConfigV2({ key: 'custom_form_register', user_id: 'manager' });
2205
2193
 
2206
2194
  register_form.list = register_form.list ?? [];
2207
2195
  FormCheck.initialRegisterForm(register_form.list);
2208
2196
 
2197
+ const userDataVerify = await redis.getValue(`verify-${userData.userData.email}`);
2198
+ const parDataVerify = await redis.getValue(`verify-${par.userData.email}`);
2199
+
2200
+ // 更改密碼驗證
2209
2201
  if (par.userData.pwd) {
2210
- if ((await redis.getValue(`verify-${userData.userData.email}`)) === par.userData.verify_code) {
2202
+ if (userDataVerify === par.userData.verify_code) {
2203
+ const pwd = await tool.hashPwd(par.userData.pwd);
2211
2204
  await db.query(
2212
- `update \`${this.app}\`.\`t_user\`
2213
- set pwd=?
2214
- where userID = ${db.escape(userID)}`,
2215
- [await tool.hashPwd(par.userData.pwd)]
2205
+ `UPDATE \`${this.app}\`.t_user SET pwd = ? WHERE userID = ${db.escape(userID)}
2206
+ `,
2207
+ [pwd]
2216
2208
  );
2217
2209
  } else {
2218
- throw exception.BadRequestError('BAD_REQUEST', 'Verify code error.', {
2219
- msg: 'email-verify-false',
2210
+ throw exception.BadRequestError('BAD_REQUEST', 'Password verify code error.', {
2211
+ msg: 'password-verify-false',
2220
2212
  });
2221
2213
  }
2222
2214
  }
2223
2215
 
2216
+ // 更改信箱驗證
2224
2217
  if (par.userData.email && par.userData.email !== userData.userData.email) {
2225
2218
  const count = (
2226
2219
  await db.query(
2227
- `select count(1)
2228
- from \`${this.app}\`.\`t_user\`
2229
- where (userData ->>'$.email' = ${db.escape(par.userData.email)})
2230
- and (userID != ${db.escape(userID)}) `,
2220
+ `SELECT count(1)
2221
+ FROM \`${this.app}\`.t_user
2222
+ WHERE (userData->>'$.email' = ${db.escape(par.userData.email)})
2223
+ AND (userID != ${db.escape(userID)})`,
2231
2224
  []
2232
2225
  )
2233
2226
  )[0]['count(1)'];
2227
+
2234
2228
  if (count) {
2235
- throw exception.BadRequestError('BAD_REQUEST', 'Already exists.', {
2229
+ throw exception.BadRequestError('BAD_REQUEST', 'User email already exists.', {
2236
2230
  msg: 'email-exists',
2237
2231
  });
2238
2232
  }
2233
+
2239
2234
  if (
2235
+ !manager &&
2240
2236
  login_config.email_verify &&
2241
- par.userData.verify_code !== (await redis.getValue(`verify-${par.userData.email}`)) &&
2242
- register_form.list.find((dd: any) => {
2243
- return dd.key === 'email' && `${dd.hidden}` !== 'true';
2244
- })
2237
+ par.userData.verify_code !== parDataVerify &&
2238
+ register_form.list.some((r: any) => r.key === 'email' && `${r.hidden}` !== 'true')
2245
2239
  ) {
2246
- throw exception.BadRequestError('BAD_REQUEST', 'Verify code error.', {
2240
+ throw exception.BadRequestError('BAD_REQUEST', 'ParData email verify code error.', {
2247
2241
  msg: 'email-verify-false',
2248
2242
  });
2249
2243
  }
2250
2244
  }
2251
2245
 
2246
+ // 更改手機驗證
2252
2247
  if (par.userData.phone && par.userData.phone !== userData.userData.phone) {
2253
2248
  const count = (
2254
2249
  await db.query(
2255
- `select count(1)
2256
- from \`${this.app}\`.\`t_user\`
2257
- where (userData ->>'$.phone' = ${db.escape(par.userData.phone)})
2258
- and (userID != ${db.escape(userID)}) `,
2250
+ `SELECT count(1)
2251
+ FROM \`${this.app}\`.t_user
2252
+ WHERE (userData->>'$.phone' = ${db.escape(par.userData.phone)})
2253
+ AND (userID != ${db.escape(userID)}) `,
2259
2254
  []
2260
2255
  )
2261
2256
  )[0]['count(1)'];
2257
+
2262
2258
  if (count) {
2263
- throw exception.BadRequestError('BAD_REQUEST', 'Already exists.', {
2259
+ throw exception.BadRequestError('BAD_REQUEST', 'User phone already exists.', {
2264
2260
  msg: 'phone-exists',
2265
2261
  });
2266
2262
  }
2263
+
2267
2264
  if (
2265
+ !manager &&
2268
2266
  login_config.phone_verify &&
2269
2267
  !(await PhoneVerify.verify(par.userData.phone, par.userData.verify_code_phone)) &&
2270
- register_form.list.find((dd: any) => {
2271
- return dd.key === 'phone' && `${dd.hidden}` !== 'true';
2272
- })
2268
+ register_form.list.some((dd: any) => dd.key === 'phone' && `${dd.hidden}` !== 'true')
2273
2269
  ) {
2274
- throw exception.BadRequestError('BAD_REQUEST', 'Verify code error.', {
2270
+ throw exception.BadRequestError('BAD_REQUEST', 'ParData phone verify code error.', {
2275
2271
  msg: 'phone-verify-false',
2276
2272
  });
2277
2273
  }
@@ -2282,10 +2278,8 @@ export class User {
2282
2278
 
2283
2279
  if (par.userData.phone) {
2284
2280
  await db.query(
2285
- `update \`${this.app}\`.t_checkout
2286
- set email=?
2287
- where id > 0
2288
- and email = ?`,
2281
+ `UPDATE \`${this.app}\`.t_checkout SET email = ? WHERE id > 0 AND email = ?
2282
+ `,
2289
2283
  [par.userData.phone, `${userData.userData.phone}`]
2290
2284
  );
2291
2285
  userData.account = par.userData.phone;
@@ -2293,10 +2287,8 @@ export class User {
2293
2287
 
2294
2288
  if (par.userData.email) {
2295
2289
  await db.query(
2296
- `update \`${this.app}\`.t_checkout
2297
- set email=?
2298
- where id > 0
2299
- and email = ?`,
2290
+ `UPDATE \`${this.app}\`.t_checkout SET email = ? WHERE id > 0 AND email = ?
2291
+ `,
2300
2292
  [par.userData.email, `${userData.userData.email}`]
2301
2293
  );
2302
2294
  userData.account = par.userData.email;
@@ -2304,8 +2296,8 @@ export class User {
2304
2296
 
2305
2297
  par.userData = await this.checkUpdate({
2306
2298
  updateUserData: par.userData,
2307
- userID: userID,
2308
- manager: manager,
2299
+ userID,
2300
+ manager,
2309
2301
  });
2310
2302
 
2311
2303
  delete par.userData.verify_code;
@@ -2320,13 +2312,11 @@ export class User {
2320
2312
  delete par.account;
2321
2313
  }
2322
2314
 
2323
- const data = (await db.query(
2324
- `update \`${this.app}\`.t_user
2325
- SET ?
2326
- WHERE 1 = 1
2327
- and userID = ?`,
2315
+ const data = await db.query(
2316
+ `UPDATE \`${this.app}\`.t_user SET ? WHERE 1 = 1 AND userID = ?
2317
+ `,
2328
2318
  [par, userID]
2329
- )) as any;
2319
+ );
2330
2320
 
2331
2321
  await UserUpdate.update(this.app, userID);
2332
2322