Skip to content

Commit

Permalink
🐛 [Fix]: 토큰 없어도 채팅방 입장 가능하게 수정
Browse files Browse the repository at this point in the history
🐛 [Fix]: 토큰 없어도 채팅방 입장 가능하게 수정
  • Loading branch information
seungheon123 authored Dec 3, 2024
2 parents 9b355bb + f958745 commit ca00b00
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions apps/chat/src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ChatService {
async createRoom(roomId: string, client: Socket) {
const response = await this.memberService.getMemberInfo(client.token);
const member = response.data;
console.log(member);

const newClient = new Client(member.camperId, member.name, client);

const room = {
Expand All @@ -41,17 +41,14 @@ export class ChatService {

async joinRoom(roomId: string, client: Socket) {
let member: { camperId: string; name: string } | null = null;

if (client.token) {
const response = await this.memberService.getMemberInfo(client.token);
const token = client.handshake.headers.authorization?.split(' ')[1];
if (token) {
const response = await this.memberService.getMemberInfo(token);
member = response.data;
}

const room = this.rooms.get(roomId);
if (!room) throw new CustomWsException(ErrorStatus.ROOM_NOT_FOUND);

const newClient = new Client(member?.camperId || '', member?.name || '', client);

room.clients.set(client.id, newClient);
this.clientToRoom.set(client.id, roomId);
this.logger.log(`Client Join Room: ${roomId}`);
Expand Down

0 comments on commit ca00b00

Please sign in to comment.