From 5e9e68293288336707b176ed10afc9e7a0df5245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 2 Mar 2018 11:40:39 +0100 Subject: [PATCH] Correct error-message on song-get on protected list --- server/routing/client/api.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/server/routing/client/api.js b/server/routing/client/api.js index 21ebcdaf..c04636ea 100644 --- a/server/routing/client/api.js +++ b/server/routing/client/api.js @@ -209,7 +209,6 @@ router.route('/api/conf/:channel_name').put(function(req, res) { typeof(allvideos) != "boolean" || typeof(removeplay) != "boolean" || typeof(skipping) != "boolean" || typeof(shuffling) != "boolean" || typeof(userpass_changed) != "boolean") { - console.log("crash here"); throw "Wrong format"; } } catch(e) { @@ -532,24 +531,23 @@ router.route('/api/list/:channel_name/:video_id').get(function(req, res) { searchQuery = {now_playing: true}; } db.collection(channel_name).find(searchQuery, toShowChannel, function(err, docs) { - if(docs.length > 0) { - db.collection(channel_name + "_settings").find({views: {$exists: true}}, function(err, conf) { - if(conf.length == 0) { - res.status(404).send(JSON.stringify(error.not_found.list)); - return; - } else if(conf[0].userpass != "" && conf[0].userpass != undefined) { - res.status(404).send(JSON.stringify(error.not_authenticated)); - return; - } - var to_return = error.no_error; - to_return.results = docs; - res.status(200).send(JSON.stringify(to_return)); + db.collection(channel_name + "_settings").find({views: {$exists: true}}, function(err, conf) { + if(conf.length == 0) { + res.status(404).send(JSON.stringify(error.not_found.list)); return; - }); - } else { - res.status(404).send(JSON.stringify(error.not_found.local)); + } else if(conf[0].userpass != "" && conf[0].userpass != undefined) { + res.status(404).send(JSON.stringify(error.not_authenticated)); + return; + } + if(docs.length == 0) { + res.status(404).send(JSON.stringify(error.not_found.local)); + return; + } + var to_return = error.no_error; + to_return.results = docs; + res.status(200).send(JSON.stringify(to_return)); return; - } + }); }); });