From 090bc2ad10ee7d4f81782f5d4c13e50121af8179 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 17:45:51 -0500 Subject: [PATCH] 403 all guests on /search & /search/term regardless of mobile/desktop - closes #612 --- src/routes/api.js | 48 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/routes/api.js b/src/routes/api.js index dde83ad9e8..0ba2af2a44 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -215,14 +215,18 @@ var path = require('path'), }); app.get('/search', function (req, res) { - return res.json({ - show_no_topics: 'hide', - show_no_posts: 'hide', - show_results: 'hide', - search_query: '', - posts: [], - topics: [] - }); + if (req.user && req.user.uid) { + return res.json({ + show_no_topics: 'hide', + show_no_posts: 'hide', + show_results: 'hide', + search_query: '', + posts: [], + topics: [] + }); + } else { + res.send(403); + } }); app.get('/search/:term', function (req, res, next) { @@ -254,20 +258,24 @@ var path = require('path'), }); } - async.parallel([searchPosts, searchTopics], function (err, results) { - if (err) { - return next(); - } + if (req.user && req.user.uid) { + async.parallel([searchPosts, searchTopics], function (err, results) { + if (err) { + return next(); + } - return res.json({ - show_no_topics: results[1].length ? 'hide' : '', - show_no_posts: results[0].length ? 'hide' : '', - show_results: '', - search_query: req.params.term, - posts: results[0], - topics: results[1] + return res.json({ + show_no_topics: results[1].length ? 'hide' : '', + show_no_posts: results[0].length ? 'hide' : '', + show_results: '', + search_query: req.params.term, + posts: results[0], + topics: results[1] + }); }); - }); + } else { + res.send(403); + } }); app.get('/reset', function (req, res) {