From 1449e816e11e6d9dc1c33c0e1af07f6dca1d7636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Gro=C3=9F?= Date: Mon, 17 Apr 2023 14:29:33 +0200 Subject: [PATCH] API: Don't send response if no res object is passed to auth check --- api/jsonApi.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/jsonApi.js b/api/jsonApi.js index fbcdeb8..c491099 100644 --- a/api/jsonApi.js +++ b/api/jsonApi.js @@ -12,10 +12,12 @@ const PREFIX = '/api/v1'; app.use(bodyParser.json()); -function isAuthorized(req, res) { +function isAuthorized(req, res=null) { const providedToken = req.headers['apikey']; if (providedToken !== ACCESS_TOKEN) { + if(res) { res.status(401).json({ error: 'Unauthorized' }); + } return false; }