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

fix: check token response error

上级 1df6a855
const { const {
dbCmd, dbCmd,
LOG_TYPE, LOG_TYPE,
deviceCollection, deviceCollection,
userCollection userCollection
} = require('../../common/constants') } = require('../../common/constants')
async function logout () { async function logout () {
const { const {
uniIdToken, uniIdToken,
deviceId deviceId
} = this.getUniversalClientInfo() } = this.getUniversalClientInfo()
const { const payload = await this.uniIdCommon.checkToken(
uid uniIdToken,
} = await this.uniIdCommon.checkToken( {
uniIdToken, autoRefresh: false
{ }
autoRefresh: false )
} if (payload.errCode) {
) throw payload
}
// 删除token const uid = payload.uid
await userCollection.doc(uid).update({
token: dbCmd.pull(uniIdToken) // 删除token
}) await userCollection.doc(uid).update({
token: dbCmd.pull(uniIdToken)
// 仅当device表的device_id和user_id均对应时才进行更新 })
await deviceCollection.where({
device_id: deviceId, // 仅当device表的device_id和user_id均对应时才进行更新
user_id: uid await deviceCollection.where({
}).update({ device_id: deviceId,
token_expired: 0 user_id: uid
}) }).update({
await this.middleware.uniIdLog({ token_expired: 0
data: { })
user_id: uid await this.middleware.uniIdLog({
}, data: {
type: LOG_TYPE.LOGOUT user_id: uid
}) },
return { type: LOG_TYPE.LOGOUT
errCode: 0 })
} return {
} errCode: 0
}
module.exports = { }
logout
} module.exports = {
logout
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册