q-koa 7.9.2 → 7.9.3

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.
@@ -332,6 +332,19 @@ exports.mp_login = async (ctx) => {
332
332
  openid: post.openid,
333
333
  },
334
334
  })
335
+ if (app.attributes.user.mp_openid) {
336
+ app.model.user.update(
337
+ {
338
+ mp_openid: post.openid,
339
+ },
340
+ {
341
+ where: {
342
+ id: openIdUser.user_id,
343
+ mp_openid: '',
344
+ },
345
+ }
346
+ )
347
+ }
335
348
  uid = openIdUser.user_id
336
349
  } else {
337
350
  if (post.user_id) {
@@ -343,14 +356,14 @@ exports.mp_login = async (ctx) => {
343
356
  } else {
344
357
  try {
345
358
  await app.sequelize.transaction(async (transaction) => {
346
- const user = await app.model.user.create(
347
- {
348
- mp_openid: post.openid,
349
- },
350
- {
351
- transaction,
352
- }
353
- )
359
+ const target = app.attributes.user.mp_openid
360
+ ? {
361
+ mp_openid: post.openid,
362
+ }
363
+ : {}
364
+ const user = await app.model.user.create(target, {
365
+ transaction,
366
+ })
354
367
  uid = user.id
355
368
  await app.model.mp_user.create(
356
369
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "7.9.2",
3
+ "version": "7.9.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {