Fix jwt-token

This commit is contained in:
2025-09-07 12:45:59 +02:00
parent 06c3390a1f
commit 953a206522
4 changed files with 349 additions and 3 deletions

View File

@@ -89,6 +89,19 @@ router.get('/', authenticateToken, async (req, res) => {
const expectedInterval = device.heartbeat_interval || 300;
const isOnline = timeSinceLastHeartbeat && timeSinceLastHeartbeat < (expectedInterval * 2);
// Debug logging for device status calculation
if (device.id === 1001) { // Stockholm device
console.log(`🔍 DEBUG Device ${device.id} status calculation:`);
console.log(` Now: ${now.toISOString()}`);
console.log(` Last heartbeat: ${device.last_heartbeat}`);
console.log(` Time since last: ${timeSinceLastHeartbeat} seconds`);
console.log(` Expected interval: ${expectedInterval} seconds`);
console.log(` Threshold: ${expectedInterval * 2} seconds`);
console.log(` Is online: ${isOnline}`);
console.log(` Is active: ${device.is_active}`);
console.log(` Final status: ${device.is_active ? (isOnline ? 'online' : 'offline') : 'inactive'}`);
}
return {
...device.toJSON(),
stats: {