This commit is contained in:
2026-01-07 20:01:01 +01:00
parent c225a9f48d
commit 6387d4a373
2 changed files with 10 additions and 2 deletions

View File

@@ -3,6 +3,10 @@ import * as roomService from './rooms.service';
import { getUserById } from '../user/user.service'; import { getUserById } from '../user/user.service';
import jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import {getConfig} from '../../shared/config';
const { values } = getConfig();
const jwtSecret = values.server?.jwt_secret;
interface WSClient { interface WSClient {
socket: any; socket: any;
userId: string; userId: string;
@@ -68,7 +72,7 @@ async function handleWebSocketConnection(connection: any, req: any) {
// 2. MOVIDO ARRIBA: Autenticar usuario PRIMERO para saber quién es // 2. MOVIDO ARRIBA: Autenticar usuario PRIMERO para saber quién es
if (token) { if (token) {
try { try {
const decoded: any = jwt.verify(token, process.env.JWT_SECRET!); const decoded: any = jwt.verify(token, jwtSecret);
realUserId = decoded.id; realUserId = decoded.id;
const user = await getUserById(realUserId); const user = await getUserById(realUserId);

View File

@@ -3,6 +3,10 @@ import * as roomService from './rooms.service';
import { getUserById } from '../user/user.service'; import { getUserById } from '../user/user.service';
import jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import {getConfig} from '../../shared/config';
const { values } = getConfig();
const jwtSecret = values.server?.jwt_secret;
interface WSClient { interface WSClient {
socket: any; socket: any;
userId: string; userId: string;
@@ -68,7 +72,7 @@ async function handleWebSocketConnection(connection: any, req: any) {
// 2. MOVIDO ARRIBA: Autenticar usuario PRIMERO para saber quién es // 2. MOVIDO ARRIBA: Autenticar usuario PRIMERO para saber quién es
if (token) { if (token) {
try { try {
const decoded: any = jwt.verify(token, process.env.JWT_SECRET!); const decoded: any = jwt.verify(token, jwtSecret);
realUserId = decoded.id; realUserId = decoded.id;
const user = await getUserById(realUserId); const user = await getUserById(realUserId);