Fix jwt-token
This commit is contained in:
@@ -433,9 +433,9 @@ router.put('/:id', authenticateToken, validateRequest(updateDeviceSchema), async
|
||||
|
||||
await device.update(req.body);
|
||||
|
||||
// Emit real-time update (only if io is available)
|
||||
if (req.io) {
|
||||
req.io.emit('device_updated', device);
|
||||
// Emit real-time update to tenant room only
|
||||
if (req.io && device.tenant_id) {
|
||||
req.io.to(`tenant_${device.tenant_id}`).emit('device_updated', device);
|
||||
}
|
||||
|
||||
console.log(`✅ Device ${req.params.id} updated successfully`);
|
||||
@@ -564,10 +564,10 @@ router.post('/:id/approve', async (req, res) => {
|
||||
is_active: approved // Set device as active when approved, inactive when unapproved
|
||||
});
|
||||
|
||||
// Emit real-time notification
|
||||
// Emit real-time notification to tenant room only
|
||||
const { io } = require('../index');
|
||||
if (io) {
|
||||
io.emit('device_approval_updated', {
|
||||
if (io && device.tenant_id) {
|
||||
io.to(`tenant_${device.tenant_id}`).emit('device_approval_updated', {
|
||||
device_id: deviceId,
|
||||
approved: approved,
|
||||
timestamp: new Date().toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user