From e56ef979751ff0bf9013632ee779f72eb50efb00 Mon Sep 17 00:00:00 2001 From: Pitu <7425261+Pitu@users.noreply.github.com> Date: Wed, 4 Oct 2017 00:59:05 -0300 Subject: [PATCH] Return 404 for deleted albums --- controllers/albumsController.js | 2 +- routes/album.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/albumsController.js b/controllers/albumsController.js index 7c9c7da..57597ca 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -106,7 +106,7 @@ albumsController.get = async (req, res, next) => { const identifier = req.params.identifier; if (identifier === undefined) return res.status(401).json({ success: false, description: 'No identifier provided' }); - const album = await db.table('albums').where('identifier', identifier).first(); + const album = await db.table('albums').where({ identifier, enabled: 1 }).first(); if (!album) return res.json({ success: false, description: 'Album not found' }); const title = album.name; diff --git a/routes/album.js b/routes/album.js index ab1ddfa..db9dbd0 100644 --- a/routes/album.js +++ b/routes/album.js @@ -8,8 +8,8 @@ routes.get('/a/:identifier', async (req, res, next) => { let identifier = req.params.identifier; if (identifier === undefined) return res.status(401).json({ success: false, description: 'No identifier provided' }); - const album = await db.table('albums').where('identifier', identifier).first(); - if (!album) return res.json({ success: false, description: 'Album not found' }); + const album = await db.table('albums').where({ identifier, enabled: 1 }).first(); + if (!album) return res.status(404).sendFile('404.html', { root: './pages/error/' }); const files = await db.table('files').select('name').where('albumid', album.id).orderBy('id', 'DESC'); let thumb = '';