This commit is contained in:
熊潇 2025-05-21 00:36:45 +08:00
parent e5111227fd
commit 8619bf4139

View File

@ -52,9 +52,11 @@ app
ctx.throw(400, 'Invalid state'); ctx.throw(400, 'Invalid state');
return; return;
} }
ctx.body = { try {
token, ctx.body = JSON.parse(token);
}; } catch (error) {
ctx.throw(500, 'Invalid token get');
}
}) })
.addTo(app); .addTo(app);
@ -70,7 +72,7 @@ app
const wx = new WxServices(); const wx = new WxServices();
const token = await wx.login(code, 'mp'); const token = await wx.login(code, 'mp');
const redis = useContextKey('redis'); const redis = useContextKey('redis');
await redis.set(`wx:mp:login:${state}`, token, 'EX', 10000); // 30秒过期 await redis.set(`wx:mp:login:${state}`, JSON.stringify(token), 'EX', 10000); // 30秒过期
ctx.body = { ctx.body = {
token, token,
}; };