提交 f4e7ec75 编写于 作者: 雪洛's avatar 雪洛

fix: third party info error

上级 cc569438
......@@ -24,6 +24,7 @@ function generateQQCache ({
accessTokenExpired // App端QQ用户accessToken过期时间
} = {}) {
const platform = getQQPlatform.call(this)
const appId = this.getClientInfo().appId
let cache
switch (platform) {
case 'app':
......@@ -42,7 +43,7 @@ function generateQQCache ({
}
return {
third_party: {
[`${platform}_qq`]: cache
[`${appId}_${platform}_qq`]: cache
}
}
}
......@@ -53,6 +54,7 @@ async function getQQCache ({
key
} = {}) {
const platform = getQQPlatform.call(this)
const appId = this.getClientInfo().appId
if (!userRecord) {
const getUserRes = await userCollection.doc(uid).get()
userRecord = getUserRes.data[0]
......@@ -62,10 +64,13 @@ async function getQQCache ({
errCode: ERROR.ACCOUNT_NOT_EXISTS
}
}
return userRecord &&
userRecord.third_party &&
userRecord.third_party[`${platform}_qq`] &&
userRecord.third_party[`${platform}_qq`][key]
const thirdParty = userRecord && userRecord.third_party
if (!thirdParty) {
return
}
const qqCacheOld = thirdParty[`${platform}_qq`]
const qqCache = thirdParty[`${appId}_${platform}_qq`]
return (qqCache && qqCache[key]) || (qqCacheOld && qqCacheOld[key])
}
module.exports = {
......
......@@ -60,6 +60,7 @@ function generateWeixinCache ({
accessTokenExpired // App端微信用户accessToken过期时间
} = {}) {
const platform = getWeixinPlatform.call(this)
const appId = this.getClientInfo().appId
let cache
switch (platform) {
case 'app':
......@@ -81,7 +82,7 @@ function generateWeixinCache ({
}
return {
third_party: {
[`${platform}_weixin`]: cache
[`${appId}_${platform}_weixin`]: cache
}
}
}
......@@ -92,6 +93,7 @@ async function getWeixinCache ({
key
} = {}) {
const platform = getWeixinPlatform.call(this)
const appId = this.getClientInfo().appId
if (!userRecord) {
const getUserRes = await userCollection.doc(uid).get()
userRecord = getUserRes.data[0]
......@@ -101,10 +103,13 @@ async function getWeixinCache ({
errCode: ERROR.ACCOUNT_NOT_EXISTS
}
}
return userRecord &&
userRecord.third_party &&
userRecord.third_party[`${platform}_weixin`] &&
userRecord.third_party[`${platform}_weixin`][key]
const thirdParty = userRecord && userRecord.third_party
if (!thirdParty) {
return
}
const weixinCacheOld = thirdParty[`${platform}_weixin`]
const weixinCache = thirdParty[`${appId}_${platform}_weixin`]
return (weixinCache && weixinCache[key]) || (weixinCacheOld && weixinCacheOld[key])
}
module.exports = {
......
......@@ -11,6 +11,9 @@ const {
const {
initQQ
} = require('../../lib/third-party/index')
const {
generateQQCache
} = require('../../lib/utils/qq')
/**
* 绑定QQ
......@@ -78,11 +81,9 @@ module.exports = async function (params = {}) {
uid,
bindAccount,
extraData: {
third_party: {
[clientPlatform]: {
session_key: sessionKey
}
}
...generateQQCache.call(this, {
sessionKey
})
},
logType: LOG_TYPE.BIND_QQ
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册