fix: 修复手动解除oauth2授权后token缓存无法刷新 (#4156)
This commit is contained in:
parent
7651dd0018
commit
f6fca3483a
|
|
@ -8,6 +8,16 @@ module.exports = async (ctx) => {
|
|||
|
||||
if (token) {
|
||||
const response = await got.get(`https://api.weibo.com/2/statuses/home_timeline.json?access_token=${token}&count=100&feature=${feature}`);
|
||||
// 检查token失效
|
||||
if (response.data.error !== undefined) {
|
||||
const { app_key = '', redirect_url = ctx.request.origin + '/weibo/timeline/0' } = config.weibo;
|
||||
|
||||
ctx.status = 302;
|
||||
ctx.set({
|
||||
'Cache-Control': 'no-cache',
|
||||
});
|
||||
ctx.redirect(`https://api.weibo.com/oauth2/authorize?client_id=${app_key}&redirect_uri=${redirect_url}`);
|
||||
}
|
||||
// 获取所有表情
|
||||
const weiboEmotion = await ctx.cache.tryGet('weiboEmotion', async () => {
|
||||
const tmpEmotionList = {};
|
||||
|
|
|
|||
Loading…
Reference in New Issue