From 8f8d6f81abf3f08176cfd75744f60cf5d42fe574 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 10 Feb 2023 17:25:19 -0600 Subject: [PATCH] Fix:Upload API endpoint crashing on invalid request with no files #1473 --- server/controllers/MiscController.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/controllers/MiscController.js b/server/controllers/MiscController.js index 69e5be22..c7ef950f 100644 --- a/server/controllers/MiscController.js +++ b/server/controllers/MiscController.js @@ -19,6 +19,10 @@ class MiscController { Logger.warn('User attempted to upload without permission', req.user) return res.sendStatus(403) } + if (!req.files) { + Logger.error('Invalid request, no files') + return res.sendStatus(400) + } var files = Object.values(req.files) var title = req.body.title var author = req.body.author