Fix jwt-token

This commit is contained in:
2025-09-13 20:58:09 +02:00
parent 8a6a0a472c
commit 9b181d5e7f
4 changed files with 250 additions and 119 deletions

View File

@@ -159,10 +159,28 @@ router.get('/', authenticateToken, async (req, res) => {
// GET /api/devices/map - Get devices with location data for map display
router.get('/map', authenticateToken, async (req, res) => {
try {
// Get all active devices, including those without coordinates
// Determine tenant from request
const tenantId = await multiAuth.determineTenant(req);
if (!tenantId) {
return res.status(400).json({
success: false,
message: 'Unable to determine tenant'
});
}
const tenant = await Tenant.findOne({ where: { slug: tenantId } });
if (!tenant) {
return res.status(404).json({
success: false,
message: 'Tenant not found'
});
}
// Get active devices for this tenant only
const devices = await Device.findAll({
where: {
is_active: true
is_active: true,
tenant_id: tenant.id
},
attributes: [
'id',