From 10600571d36f695043f3f4569f9399e00b86fc1f Mon Sep 17 00:00:00 2001 From: xion Date: Sun, 2 Mar 2025 01:56:54 +0800 Subject: [PATCH] fix --- src/routes/user/me.ts | 2 +- src/routes/user/web-login.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/user/me.ts b/src/routes/user/me.ts index 25a087d..097a329 100644 --- a/src/routes/user/me.ts +++ b/src/routes/user/me.ts @@ -8,7 +8,7 @@ import { domain } from '@/modules/domain.ts'; * @param ctx * @returns */ -const createCookie = (token: any, ctx: any) => { +export const createCookie = (token: any, ctx: any) => { if (!domain) { return; } diff --git a/src/routes/user/web-login.ts b/src/routes/user/web-login.ts index 5d80328..b9fab7b 100644 --- a/src/routes/user/web-login.ts +++ b/src/routes/user/web-login.ts @@ -6,6 +6,7 @@ import jsonwebtoken from 'jsonwebtoken'; // const tokenData: Record = {}; import { redis } from '@/app.ts'; +import { createCookie } from './me.ts'; app .route({ @@ -79,9 +80,10 @@ app // const data = tokenData[loginToken]; const data = await redis.get(loginToken); if (data) { - ctx.body = data; + ctx.body = { token: data, expireTime: 0 }; } else { ctx.throw(400, 'Checked Failed'); } + createCookie(data, ctx); }) .addTo(app);