Fix jwt-token

This commit is contained in:
2025-09-18 06:04:08 +02:00
parent 993b482d56
commit c618706a72
2 changed files with 13 additions and 5 deletions

View File

@@ -306,7 +306,7 @@ router.get('/profile', authenticateToken, async (req, res) => {
tenant_id: req.user.tenant_id tenant_id: req.user.tenant_id
}); });
const { password_hash: _, ...userProfile } = req.user.toJSON(); const { password_hash: _, ...userProfile } = req.user.toJSON ? req.user.toJSON() : req.user;
console.log('📤 /users/profile - Response:', userProfile); console.log('📤 /users/profile - Response:', userProfile);

View File

@@ -67,15 +67,19 @@ class AlertService {
if (droneTypeInfo.category.includes('Military') && droneTypeInfo.name !== 'Unknown') { if (droneTypeInfo.category.includes('Military') && droneTypeInfo.name !== 'Unknown') {
// Military drones are escalated based on distance // Military drones are escalated based on distance
if (droneTypeInfo.name === 'Orlan' || droneTypeInfo.name === 'Zala' || droneTypeInfo.name === 'Eleron') { if (droneTypeInfo.name === 'Orlan' || droneTypeInfo.name === 'Zala' || droneTypeInfo.name === 'Eleron') {
// For very distant military drones (RSSI < -80), escalate to critical // For moderately distant military drones (RSSI between -87 and -80), escalate to critical
if (rssi < -80) { if (rssi <= -80 && rssi >= -87) {
threatLevel = 'critical'; threatLevel = 'critical';
description = `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} MILITARY DRONE - IMMEDIATE RESPONSE REQUIRED`; description = `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} MILITARY DRONE - IMMEDIATE RESPONSE REQUIRED`;
actionRequired = true; actionRequired = true;
console.log(`🚨 DISTANT MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Escalated to CRITICAL (RSSI: ${rssi})`); console.log(`🚨 DISTANT MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Escalated to CRITICAL (RSSI: ${rssi})`);
} else { } else {
// For closer military drones, keep distance-based assessment but enhance description // For closer military drones or very distant ones, keep distance-based assessment but enhance description
description = description.replace('IMMEDIATE THREAT:', `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} MILITARY DRONE -`); if (threatLevel === 'critical' && rssi >= -40) {
description = `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} MILITARY DRONE - IMMEDIATE THREAT`;
} else if (threatLevel === 'critical') {
description = description.replace('IMMEDIATE THREAT:', `CRITICAL THREAT: ${droneTypeInfo.name.toUpperCase()} MILITARY DRONE -`);
}
console.log(`🚨 MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Distance-based assessment (RSSI: ${rssi})`); console.log(`🚨 MILITARY DRONE DETECTED: ${droneTypeInfo.name} - Distance-based assessment (RSSI: ${rssi})`);
} }
} else { } else {
@@ -254,6 +258,10 @@ class AlertService {
const deviceIdStr = String(detection.device_id); const deviceIdStr = String(detection.device_id);
const allowedDeviceIds = rule.device_ids.map(id => String(id)); const allowedDeviceIds = rule.device_ids.map(id => String(id));
console.log(`🔍 DEBUG: Device comparison - Detection device: ${deviceIdStr} (type: ${typeof detection.device_id})`);
console.log(`🔍 DEBUG: Allowed devices: [${allowedDeviceIds.join(', ')}] (types: [${rule.device_ids.map(id => typeof id).join(', ')}])`);
console.log(`🔍 DEBUG: String comparison result: ${allowedDeviceIds.includes(deviceIdStr)}`);
if (!allowedDeviceIds.includes(deviceIdStr)) { if (!allowedDeviceIds.includes(deviceIdStr)) {
console.log(`❌ Rule "${rule.name}": Device ${detection.device_id} not in allowed devices [${rule.device_ids.join(', ')}]`); console.log(`❌ Rule "${rule.name}": Device ${detection.device_id} not in allowed devices [${rule.device_ids.join(', ')}]`);
return false; return false;