Skip to content

Commit

Permalink
๐Ÿ› fix: ์›น ์†Œ์ผ“ ๋น„์–ด์žˆ๋Š” ์ฟ ํ‚ค ์—๋Ÿฌ ๋ฌธ์ œ ํ•ด๊ฒฐ
Browse files Browse the repository at this point in the history
  • Loading branch information
xjfcnfw3 committed Nov 20, 2024
1 parent 433cc93 commit d6e5739
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/backend/src/auth/session/websocketSession.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PassportSession | undefined>((resolve) => {
return new Promise<PassportSession | null>((resolve) => {
this.sessionStore.get(cookieValue, (err: Error, session) => {
if (err || !session) {
resolve(undefined);
resolve(null);
}
resolve(session as PassportSession);
});
Expand Down

0 comments on commit d6e5739

Please sign in to comment.