Fix jwt-token
This commit is contained in:
@@ -14,6 +14,12 @@ function initializeSocketHandlers(io) {
|
||||
console.log(`Client ${socket.id} (IP: ${clientIP}) joined device room: device_${deviceId}`);
|
||||
});
|
||||
|
||||
// 🔒 SECURITY: Join tenant-specific room for multi-tenant isolation
|
||||
socket.on('join_tenant_room', (tenantId) => {
|
||||
socket.join(`tenant_${tenantId}`);
|
||||
console.log(`Client ${socket.id} (IP: ${clientIP}) joined tenant room: tenant_${tenantId}`);
|
||||
});
|
||||
|
||||
// Join dashboard room for general updates
|
||||
socket.on('join_dashboard', () => {
|
||||
socket.join('dashboard');
|
||||
@@ -26,6 +32,11 @@ function initializeSocketHandlers(io) {
|
||||
console.log(`Client ${socket.id} (IP: ${clientIP}) left device room: device_${deviceId}`);
|
||||
});
|
||||
|
||||
socket.on('leave_tenant_room', (tenantId) => {
|
||||
socket.leave(`tenant_${tenantId}`);
|
||||
console.log(`Client ${socket.id} (IP: ${clientIP}) left tenant room: tenant_${tenantId}`);
|
||||
});
|
||||
|
||||
socket.on('leave_dashboard', () => {
|
||||
socket.leave('dashboard');
|
||||
console.log(`Client ${socket.id} (IP: ${clientIP}) left dashboard room`);
|
||||
@@ -49,6 +60,10 @@ function initializeSocketHandlers(io) {
|
||||
io.to(`device_${deviceId}`).emit(event, data);
|
||||
};
|
||||
|
||||
io.emitToTenant = function(tenantId, event, data) {
|
||||
io.to(`tenant_${tenantId}`).emit(event, data);
|
||||
};
|
||||
|
||||
io.emitToDashboard = function(event, data) {
|
||||
io.to('dashboard').emit(event, data);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user