Skip to content

Commit

Permalink
๐Ÿš‘ :: hotfix :: jwt exception ์ฒ˜๋ฆฌ
Browse files Browse the repository at this point in the history
  • Loading branch information
12xii committed Dec 29, 2023
1 parent acea135 commit 19b41d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/chat/chat.gateway.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UnauthorizedException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import {
SubscribeMessage,
Expand Down Expand Up @@ -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 });

Expand All @@ -60,9 +63,9 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa
message: string,
room: string
}): Promise<null> {
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
})
Expand Down

0 comments on commit 19b41d7

Please sign in to comment.