From 3e065c26107449cec0985a4a30f55d2387e73660 Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Sat, 7 Dec 2019 17:55:51 +1030 Subject: [PATCH] Missing returns and page check --- routes/admin.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routes/admin.js b/routes/admin.js index 5780520..182dea6 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -276,6 +276,7 @@ router.post('/admin/settings/page', restrict, checkAccess, async (req, res) => { const page = await db.pages.findOne({ _id: common.getId(req.body.pageId) }); if(!page){ res.status(400).json({ message: 'Page not found' }); + return; } try{ @@ -299,6 +300,13 @@ router.post('/admin/settings/page', restrict, checkAccess, async (req, res) => { // delete page router.post('/admin/settings/page/delete', restrict, checkAccess, async (req, res) => { const db = req.app.db; + + const page = await db.pages.findOne({ _id: common.getId(req.body.pageId) }); + if(!page){ + res.status(400).json({ message: 'Page not found' }); + return; + } + try{ await db.pages.deleteOne({ _id: common.getId(req.body.pageId) }, {}); res.status(200).json({ message: 'Page successfully deleted' });