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('🔍 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
|
||||
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: 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}`);
|
||||
});
|
||||
|
||||
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');
|
||||
|
||||
if (!device) {
|
||||
@@ -297,9 +300,10 @@ async function handleDetection(req, res) {
|
||||
isDebugDetection = true;
|
||||
}
|
||||
|
||||
// Create detection record
|
||||
// Create detection record with string device_id
|
||||
const detectionRecord = {
|
||||
...detectionData,
|
||||
device_id: deviceIdString, // Use the string version for consistency
|
||||
server_timestamp: new Date()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user