From a68e664403a19369f1d80ccdc1f7d7279fdb3d59 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Thu, 28 Aug 2025 08:26:49 +0200 Subject: [PATCH] Fix jwt-token --- server/routes/dashboard.js | 9 +++++---- server/routes/device.js | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/server/routes/dashboard.js b/server/routes/dashboard.js index 0c887f3..02534c9 100644 --- a/server/routes/dashboard.js +++ b/server/routes/dashboard.js @@ -3,9 +3,10 @@ const router = express.Router(); const { DroneDetection, Device, Heartbeat } = require('../models'); const { Op } = require('sequelize'); const { sequelize } = require('../models'); +const { authenticateToken } = require('../middleware/auth'); // GET /api/dashboard/overview - Get dashboard overview statistics -router.get('/overview', async (req, res) => { +router.get('/overview', authenticateToken, async (req, res) => { try { const { hours = 24 } = req.query; const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000); @@ -98,7 +99,7 @@ router.get('/overview', async (req, res) => { }); // GET /api/dashboard/activity - Get recent activity feed -router.get('/activity', async (req, res) => { +router.get('/activity', authenticateToken, async (req, res) => { try { const { limit = 50, hours = 24 } = req.query; const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000); @@ -176,7 +177,7 @@ router.get('/activity', async (req, res) => { }); // GET /api/dashboard/charts/detections - Get detection chart data -router.get('/charts/detections', async (req, res) => { +router.get('/charts/detections', authenticateToken, async (req, res) => { try { const { hours = 24, interval = 'hour' } = req.query; const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000); @@ -226,7 +227,7 @@ router.get('/charts/detections', async (req, res) => { }); // GET /api/dashboard/charts/devices - Get device activity chart data -router.get('/charts/devices', async (req, res) => { +router.get('/charts/devices', authenticateToken, async (req, res) => { try { const { hours = 24 } = req.query; const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000); diff --git a/server/routes/device.js b/server/routes/device.js index db71c61..59e52bf 100644 --- a/server/routes/device.js +++ b/server/routes/device.js @@ -32,7 +32,7 @@ const updateDeviceSchema = Joi.object({ }); // GET /api/devices - Get all devices -router.get('/', async (req, res) => { +router.get('/', authenticateToken, async (req, res) => { try { const { include_stats = false, @@ -122,7 +122,7 @@ router.get('/', async (req, res) => { }); // GET /api/devices/map - Get devices with location data for map display -router.get('/map', async (req, res) => { +router.get('/map', authenticateToken, async (req, res) => { try { const devices = await Device.findAll({ where: { @@ -182,7 +182,7 @@ router.get('/map', async (req, res) => { }); // GET /api/devices/:id - Get specific device -router.get('/:id', async (req, res) => { +router.get('/:id', authenticateToken, async (req, res) => { try { const device = await Device.findByPk(req.params.id, { include: [ @@ -321,7 +321,7 @@ router.delete('/:id', authenticateToken, async (req, res) => { }); // GET /api/devices/pending - List devices pending approval -router.get('/pending', async (req, res) => { +router.get('/pending', authenticateToken, async (req, res) => { try { const pendingDevices = await Device.findAll({ where: { is_approved: false },