Fix jwt-token
This commit is contained in:
@@ -227,8 +227,11 @@ async function handleDetection(req, res) {
|
|||||||
console.log(`🎯 Drone Type Details: ${droneTypeInfo.category} | Threat: ${droneTypeInfo.threat_level} | ${droneTypeInfo.description}`);
|
console.log(`🎯 Drone Type Details: ${droneTypeInfo.category} | Threat: ${droneTypeInfo.threat_level} | ${droneTypeInfo.description}`);
|
||||||
console.log('🔍 Complete detection data:', JSON.stringify(detectionData, null, 2));
|
console.log('🔍 Complete detection data:', JSON.stringify(detectionData, null, 2));
|
||||||
|
|
||||||
|
// Convert device_id to string for consistent database lookup
|
||||||
|
const deviceIdString = String(detectionData.device_id);
|
||||||
|
|
||||||
// Check if device exists and is approved
|
// Check if device exists and is approved
|
||||||
console.log(`🔍 DEBUG: Looking for device with ID: ${detectionData.device_id} (type: ${typeof detectionData.device_id})`);
|
console.log(`🔍 DEBUG: Looking for device with ID: ${detectionData.device_id} (type: ${typeof detectionData.device_id}) -> converted to "${deviceIdString}" (string)`);
|
||||||
console.log(`🔍 DEBUG: Device model being used:`, Device);
|
console.log(`🔍 DEBUG: Device model being used:`, Device);
|
||||||
console.log(`🔍 DEBUG: Sequelize instance:`, Device.sequelize.constructor.name);
|
console.log(`🔍 DEBUG: Sequelize instance:`, Device.sequelize.constructor.name);
|
||||||
|
|
||||||
@@ -239,7 +242,7 @@ async function handleDetection(req, res) {
|
|||||||
console.log(` - Device ID: ${d.id} (type: ${typeof d.id}), name: ${d.name}, approved: ${d.is_approved}, active: ${d.is_active}`);
|
console.log(` - Device ID: ${d.id} (type: ${typeof d.id}), name: ${d.name}, approved: ${d.is_approved}, active: ${d.is_active}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
let device = await Device.findOne({ where: { id: detectionData.device_id } });
|
let device = await Device.findOne({ where: { id: deviceIdString } });
|
||||||
console.log(`🔍 DEBUG: Device lookup result:`, device ? `Found device ${device.id}` : 'Device not found');
|
console.log(`🔍 DEBUG: Device lookup result:`, device ? `Found device ${device.id}` : 'Device not found');
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
@@ -297,9 +300,10 @@ async function handleDetection(req, res) {
|
|||||||
isDebugDetection = true;
|
isDebugDetection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create detection record
|
// Create detection record with string device_id
|
||||||
const detectionRecord = {
|
const detectionRecord = {
|
||||||
...detectionData,
|
...detectionData,
|
||||||
|
device_id: deviceIdString, // Use the string version for consistency
|
||||||
server_timestamp: new Date()
|
server_timestamp: new Date()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user