fix
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user