From 19b41d750fb1b435278c653eec022e7ed1a195cf Mon Sep 17 00:00:00 2001 From: Yu NaHyun Date: Fri, 29 Dec 2023 11:01:11 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20::=20hotfix=20::=20jwt=20excepti?= =?UTF-8?q?on=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/chat.gateway.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/chat/chat.gateway.ts b/src/chat/chat.gateway.ts index 3a14147..9bfeef9 100644 --- a/src/chat/chat.gateway.ts +++ b/src/chat/chat.gateway.ts @@ -1,3 +1,4 @@ +import { UnauthorizedException } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { SubscribeMessage, @@ -34,6 +35,8 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa // JWT 유효성 검사 const { userID } = await this.userService.validateAccess(socket.handshake.headers.authorization); + if(!userID) throw new UnauthorizedException() + // 유저가 속한 채팅방 찾기 const groupList = await this.groupMappingEntity.findBy({ userID }); @@ -60,9 +63,9 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa message: string, room: string }): Promise { - const thisUser = (await this.userService.validateAccess(client.client.request.headers.authorization)).userID + const { userID } = (await this.userService.validateAccess(client.client.request.headers.authorization)) this.server.to(data.room).emit('message', { - userID: thisUser, + userID, message: data.message, room: data.room })