Fix jwt-token
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user