q-koa 13.8.25 → 13.8.26
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.
|
@@ -7,7 +7,6 @@ exports.login = async (ctx) => {
|
|
|
7
7
|
const appConfig = getConfig(app)
|
|
8
8
|
const { is_dev } = await appConfig.getObject('base')
|
|
9
9
|
const { uuid } = ctx.request.body
|
|
10
|
-
console.log(uuid)
|
|
11
10
|
if (!app.attributes.user.uuid) throw new Error(`没有uuid字段`)
|
|
12
11
|
|
|
13
12
|
const hasUser = await app.model.user.findOne({
|
|
@@ -92,12 +92,12 @@ exports.login_callback = async (ctx) => {
|
|
|
92
92
|
const rest = userInfoResult.data
|
|
93
93
|
const post = lodash.pickBy(
|
|
94
94
|
{
|
|
95
|
-
nick_name:
|
|
96
|
-
avatar:
|
|
97
|
-
country:
|
|
98
|
-
city:
|
|
99
|
-
province:
|
|
100
|
-
gender:
|
|
95
|
+
nick_name: rest.nickname ?? null,
|
|
96
|
+
avatar: rest.avatar ?? null,
|
|
97
|
+
country: rest.country ?? null,
|
|
98
|
+
city: rest.city ?? null,
|
|
99
|
+
province: rest.province ?? null,
|
|
100
|
+
gender: rest.gender ?? null,
|
|
101
101
|
openid: rest.open_id,
|
|
102
102
|
user_id: user_id ? Number(user_id) : null,
|
|
103
103
|
access_token: access_token || '',
|
|
@@ -207,7 +207,6 @@ exports.createImg = async (ctx) => {
|
|
|
207
207
|
// const result = await axios.get(url, {
|
|
208
208
|
// client_key: app_id,
|
|
209
209
|
// }).then(res => res.data)
|
|
210
|
-
console.log('失败先检查client_key')
|
|
211
210
|
const img = qr.image(url, {
|
|
212
211
|
size: 2,
|
|
213
212
|
})
|
|
@@ -98,18 +98,17 @@ exports.login = async (ctx) => {
|
|
|
98
98
|
|
|
99
99
|
if (!openid) {
|
|
100
100
|
const msg = `找不到openid, errcode:${res.errcode} app_id:${app_id} app_secrect:${app_secrect}`
|
|
101
|
-
|
|
102
|
-
throw new Error('头条登录失败')
|
|
101
|
+
throw new Error(msg)
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
const post = lodash.pickBy(
|
|
106
105
|
{
|
|
107
|
-
nick_name:
|
|
108
|
-
avatar:
|
|
109
|
-
country:
|
|
110
|
-
city:
|
|
111
|
-
province:
|
|
112
|
-
gender:
|
|
106
|
+
nick_name: rest.nickName ?? null,
|
|
107
|
+
avatar: rest.avatarUrl ?? null,
|
|
108
|
+
country: rest.country ?? null,
|
|
109
|
+
city: rest.city ?? null,
|
|
110
|
+
province: rest.province ?? null,
|
|
111
|
+
gender: rest.gender ?? null,
|
|
113
112
|
openid,
|
|
114
113
|
user_id: lodash.get(ctx.request, `${appName}-user.id`, null),
|
|
115
114
|
},
|
|
@@ -338,10 +338,10 @@ exports.mp_login = async (ctx) => {
|
|
|
338
338
|
|
|
339
339
|
const post = lodash.pickBy(
|
|
340
340
|
{
|
|
341
|
-
nick_name:
|
|
342
|
-
avatar:
|
|
341
|
+
nick_name: rest.nickName ?? null,
|
|
342
|
+
avatar: rest.avatarUrl ?? null,
|
|
343
343
|
openid,
|
|
344
|
-
unionid:
|
|
344
|
+
unionid: res.unionid ?? null,
|
|
345
345
|
appid: app_id,
|
|
346
346
|
user_id: lodash.get(ctx.request, `${appName}-user.id`, null),
|
|
347
347
|
},
|
|
@@ -368,6 +368,7 @@ exports.mp_login = async (ctx) => {
|
|
|
368
368
|
*/
|
|
369
369
|
|
|
370
370
|
const openIdUser = await app.model.mp_user.findOne({
|
|
371
|
+
attributes: ['id', 'user_id', 'openid'],
|
|
371
372
|
where: {
|
|
372
373
|
openid: post.openid,
|
|
373
374
|
},
|
|
@@ -375,14 +376,12 @@ exports.mp_login = async (ctx) => {
|
|
|
375
376
|
|
|
376
377
|
let uid
|
|
377
378
|
if (openIdUser) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
{
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
)
|
|
379
|
+
const { user_id: _omit, ...updatePost } = post
|
|
380
|
+
await app.model.mp_user.update(updatePost, {
|
|
381
|
+
where: {
|
|
382
|
+
openid: post.openid,
|
|
383
|
+
},
|
|
384
|
+
})
|
|
386
385
|
if (app.attributes.user.mp_openid) {
|
|
387
386
|
app.model.user.update(
|
|
388
387
|
{
|
|
@@ -428,8 +427,7 @@ exports.mp_login = async (ctx) => {
|
|
|
428
427
|
)
|
|
429
428
|
})
|
|
430
429
|
} catch (e) {
|
|
431
|
-
|
|
432
|
-
throw new Error(e)
|
|
430
|
+
throw e
|
|
433
431
|
}
|
|
434
432
|
}
|
|
435
433
|
}
|
|
@@ -606,7 +604,6 @@ exports.h5_login_callback = async (ctx) => {
|
|
|
606
604
|
new Promise((resolve, reject) => {
|
|
607
605
|
client.getAccessToken(c, (err, result) => {
|
|
608
606
|
if (err) {
|
|
609
|
-
console.log('err===', err)
|
|
610
607
|
return reject(err.data)
|
|
611
608
|
}
|
|
612
609
|
return resolve(result.data)
|
|
@@ -616,15 +613,14 @@ exports.h5_login_callback = async (ctx) => {
|
|
|
616
613
|
|
|
617
614
|
const post = lodash.pickBy(
|
|
618
615
|
{
|
|
619
|
-
nick_name:
|
|
620
|
-
avatar:
|
|
616
|
+
nick_name: data.nickname ?? null,
|
|
617
|
+
avatar: data.headimgurl ?? null,
|
|
621
618
|
openid: data.openid,
|
|
622
619
|
appid: app_id,
|
|
623
620
|
user_id: user_id ? Number(user_id) : null,
|
|
624
621
|
},
|
|
625
622
|
(item) => item !== null
|
|
626
623
|
)
|
|
627
|
-
console.log('post', post)
|
|
628
624
|
/**
|
|
629
625
|
* 查询是否已经有openid
|
|
630
626
|
*
|
|
@@ -644,6 +640,7 @@ exports.h5_login_callback = async (ctx) => {
|
|
|
644
640
|
*/
|
|
645
641
|
|
|
646
642
|
const openIdUser = await app.model.h5_user.findOne({
|
|
643
|
+
attributes: ['id', 'user_id', 'openid'],
|
|
647
644
|
where: {
|
|
648
645
|
openid: post.openid,
|
|
649
646
|
},
|
|
@@ -743,26 +740,23 @@ exports.h5_login_info_callback = async (ctx) => {
|
|
|
743
740
|
new Promise((resolve, reject) => {
|
|
744
741
|
client.getUserByCode(c, (err, result) => {
|
|
745
742
|
if (err) {
|
|
746
|
-
console.log('err===', err)
|
|
747
743
|
return reject(err.data)
|
|
748
744
|
}
|
|
749
745
|
return resolve(result)
|
|
750
746
|
})
|
|
751
747
|
})
|
|
752
748
|
const data = await getUserByCode(`${code}`)
|
|
753
|
-
console.log('========', data)
|
|
754
749
|
|
|
755
750
|
const post = lodash.pickBy(
|
|
756
751
|
{
|
|
757
|
-
nick_name:
|
|
758
|
-
avatar:
|
|
752
|
+
nick_name: data.nickname ?? null,
|
|
753
|
+
avatar: data.headimgurl ?? null,
|
|
759
754
|
openid: data.openid,
|
|
760
755
|
appid: app_id,
|
|
761
756
|
user_id: user_id ? Number(user_id) : null,
|
|
762
757
|
},
|
|
763
758
|
(item) => item !== null
|
|
764
759
|
)
|
|
765
|
-
console.log('post', post)
|
|
766
760
|
/**
|
|
767
761
|
* 查询是否已经有openid
|
|
768
762
|
*
|
|
@@ -782,6 +776,7 @@ exports.h5_login_info_callback = async (ctx) => {
|
|
|
782
776
|
*/
|
|
783
777
|
|
|
784
778
|
const openIdUser = await app.model.h5_user.findOne({
|
|
779
|
+
attributes: ['id', 'user_id', 'openid'],
|
|
785
780
|
where: {
|
|
786
781
|
openid: post.openid,
|
|
787
782
|
},
|