From d6e573948c98a8be3b2bbc6c2abafdcb1bcb5937 Mon Sep 17 00:00:00 2001 From: kimminsu Date: Wed, 20 Nov 2024 23:03:18 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=EC=9B=B9=20=EC=86=8C?= =?UTF-8?q?=EC=BC=93=20=EB=B9=84=EC=96=B4=EC=9E=88=EB=8A=94=20=EC=BF=A0?= =?UTF-8?q?=ED=82=A4=20=EC=97=90=EB=9F=AC=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/auth/session/websocketSession.service.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/auth/session/websocketSession.service.ts b/packages/backend/src/auth/session/websocketSession.service.ts index 10af73c2..c6c248cc 100644 --- a/packages/backend/src/auth/session/websocketSession.service.ts +++ b/packages/backend/src/auth/session/websocketSession.service.ts @@ -7,16 +7,21 @@ export class WebsocketSessionService { constructor(private readonly sessionStore: MemoryStore) {} async getAuthenticatedUser(socket: Socket) { - const cookieValue = websocketCookieParse(socket); - const session = await this.getSession(cookieValue); - return session ? session.passport.user : undefined; + try { + const cookieValue = websocketCookieParse(socket); + const session = await this.getSession(cookieValue); + return session ? session.passport.user : null; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } catch (e) { + return null; + } } private getSession(cookieValue: string) { - return new Promise((resolve) => { + return new Promise((resolve) => { this.sessionStore.get(cookieValue, (err: Error, session) => { if (err || !session) { - resolve(undefined); + resolve(null); } resolve(session as PassportSession); });