From 8619bf413969909f520f0daba7b5fecc6e139b59 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Wed, 21 May 2025 00:36:45 +0800 Subject: [PATCH] perf --- app/src/routes/wx/login.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/routes/wx/login.ts b/app/src/routes/wx/login.ts index 95f6dd1..9f35a90 100644 --- a/app/src/routes/wx/login.ts +++ b/app/src/routes/wx/login.ts @@ -52,9 +52,11 @@ app ctx.throw(400, 'Invalid state'); return; } - ctx.body = { - token, - }; + try { + ctx.body = JSON.parse(token); + } catch (error) { + ctx.throw(500, 'Invalid token get'); + } }) .addTo(app); @@ -70,7 +72,7 @@ app const wx = new WxServices(); const token = await wx.login(code, 'mp'); 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 = { token, };