Skip to content

Commit e24ba53

Browse files
fix(auth): update user identification from userId to username in authentication middleware
1 parent b44144c commit e24ba53

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

backend/collaboration-service/src/middleware/auth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const authenticateWebSocket = async (req) => {
2323

2424
return {
2525
success: true,
26-
userId: decoded.userId,
26+
userId: decoded.username,
2727
};
2828
} catch (err) {
2929
return {
@@ -62,7 +62,7 @@ export const authenticateHttp = async (req, res, next) => {
6262
const decoded = jwt.verify(token, process.env.JWT_SECRET);
6363

6464
// Attach user ID to request
65-
req.userId = decoded.userId;
65+
req.userId = decoded.username;
6666

6767
next();
6868
} catch (err) {

backend/matching-service/src/middleware/auth-socket.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface AuthenticatedSocket extends Socket {
88
}
99

1010
interface JWTPayload {
11-
userId: string;
11+
username: string;
1212
[key: string]: any;
1313
}
1414

@@ -51,10 +51,10 @@ export const authenticateSocket = async (socket: Socket, next: (err?: Error) =>
5151
const decoded = jwt.verify(token, process.env.JWT_SECRET!) as JWTPayload;
5252

5353
(socket as AuthenticatedSocket).data = {
54-
userId: decoded.userId
54+
userId: decoded.username
5555
};
5656

57-
console.log('Socket authenticated for userId:', decoded.userId);
57+
console.log('Socket authenticated for userId:', decoded.username);
5858
next();
5959

6060
} catch (err: any) {

0 commit comments

Comments
 (0)