diff --git a/package.json b/package.json index 636c2a8..5cd288d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ }, "scripts": { "dev": "bun run --watch --hot src/index.ts", - "cmd": "bun run src/run.ts ", + "cli": "bun run src/cli.ts ", "prebuild": "rimraf dist && rimraf pack-dist", "build": "NODE_ENV=production bun bun.config.mjs", "postbuild": "ev pack", diff --git a/src/auth/oauth/oauth.ts b/src/auth/oauth/oauth.ts index 2413a6c..95cd9d3 100644 --- a/src/auth/oauth/oauth.ts +++ b/src/auth/oauth/oauth.ts @@ -166,7 +166,6 @@ export class RedisTokenStore implements Store { } else { expire = Math.min(expire, 60 * 60 * 24 * 30); // 默认的过期时间最大为30天 } - await this.set(accessToken, JSON.stringify(value), expire); await this.set(userPrefix + ':token:' + accessToken, accessToken, expire); // refreshToken的过期时间比accessToken多expireDay天,确保在accessToken过期后,refreshToken仍然有效 diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 0000000..611cbe8 --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,8 @@ +import { parse } from '@kevisual/router/commander' + +import { app } from './app.ts'; +import './route.ts'; + +parse({ + app, +}) \ No newline at end of file diff --git a/src/modules/auth.ts b/src/modules/auth.ts index f9baf61..39cd219 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -52,6 +52,7 @@ export const getLoginUserByToken = async (token: string) => { let tokenUser; try { tokenUser = await User.verifyToken(token); + if (!tokenUser) return null; return { tokenUser, token }; } catch (e) { return null; @@ -66,6 +67,7 @@ export const getLoginUser = async (req: http.IncomingMessage) => { logger.debug('getLoginUser', token); try { tokenUser = await User.verifyToken(token); + if (!tokenUser) return null; return { tokenUser, token }; } catch (e) { return null; diff --git a/src/modules/v1-ws-proxy/index.ts b/src/modules/v1-ws-proxy/index.ts index 90c7c29..033a537 100644 --- a/src/modules/v1-ws-proxy/index.ts +++ b/src/modules/v1-ws-proxy/index.ts @@ -26,7 +26,6 @@ export const wssFun: WebSocketListenerFun = async (req, res) => { } if (!user) { logger.debug('未提供用户名,无法注册 ws 连接'); - ws.close(); return; } let userApp = user + '--' + id;