Fix jwt-token
This commit is contained in:
@@ -478,8 +478,19 @@ router.delete('/:id', authenticateToken, async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Soft delete by setting is_active to false
|
// Check if device belongs to user's tenant
|
||||||
await device.update({ is_active: false });
|
const tenantId = await multiAuth.determineTenant(req);
|
||||||
|
const tenant = await Tenant.findOne({ where: { slug: tenantId } });
|
||||||
|
|
||||||
|
if (device.tenant_id !== tenant.id) {
|
||||||
|
return res.status(404).json({
|
||||||
|
success: false,
|
||||||
|
message: 'Device not found'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actually delete the device
|
||||||
|
await device.destroy();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user