|
|
@ -128,8 +128,44 @@ async function invalidate (ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function invalidateAll (ctx) { |
|
|
|
// 给其他系统删除token
|
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { appKey } = ctx.query; |
|
|
|
|
|
|
|
const tokenRes = await models.UserToken.findAll({ |
|
|
|
where: { |
|
|
|
'userInfo.appKey': appKey |
|
|
|
} |
|
|
|
}) |
|
|
|
// 删除token
|
|
|
|
await models.UserToken.destroy({ |
|
|
|
where: { 'userInfo.appKey': appKey }, |
|
|
|
transaction |
|
|
|
}); |
|
|
|
tokenRes.forEach(async t => { |
|
|
|
await ctx.redisTools.hdelall(t.token); |
|
|
|
}) |
|
|
|
|
|
|
|
await transaction.commit(); |
|
|
|
ctx.status = 204; |
|
|
|
} catch (e) { |
|
|
|
await transaction.rollback(); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { |
|
|
|
name: 'RequestError', |
|
|
|
message: e.message |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// OAUTH2.0 END
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
apply, |
|
|
|
refresh, |
|
|
|
invalidate |
|
|
|
invalidate, |
|
|
|
invalidateAll, // 给其他系统删除token
|
|
|
|
} |