Skip to content

Commit

Permalink
Merge pull request #10 from internxt/fix/use-uuid-for-joining-a-room
Browse files Browse the repository at this point in the history
[_]: fix/use-user-uuid-to-join-a-room
  • Loading branch information
sg-gs authored Sep 22, 2022
2 parents 14181fe + 03457c8 commit 3246bc6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/auth-socket-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ export default function registerAuthSocketMiddleware(io: Server) {
logger.warn(`Failed to verify a token, error: ${JSON.stringify(err, null, 2)}`);
next(new Error());
}
logger.info(`Token decoded: ${decoded}`);
logger.info(`Token decoded: ${JSON.stringify(decoded, null, 2)}`);

if (decoded && typeof decoded !== 'string' && decoded.userId) {
logger.info(`userId: ${decoded.userId} is listening notifications`);
socket.join(decoded.userId);
if (
decoded &&
typeof decoded !== 'string' &&
decoded.payload &&
decoded.payload.uuid
) {
const uuid = decoded.payload.uuid;
logger.info(`user: ${uuid} is listening notifications`);
socket.join(uuid);
} else {
const email = typeof decoded === 'string' ? decoded : decoded!.email;
logger.info(`email: ${email} is listening notifications`);
Expand Down

0 comments on commit 3246bc6

Please sign in to comment.