From 83aaef0f824e8776ddf4c60a44e6d56c21a0efcc Mon Sep 17 00:00:00 2001 From: Pitu Date: Thu, 19 Jan 2017 02:37:35 -0300 Subject: Changed request system and post data Changed from XMLHttpRequest to Axiios and made every POST call to look for params or json and not pass the values as headers. Token is still a header though --- controllers/albumsController.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'controllers/albumsController.js') diff --git a/controllers/albumsController.js b/controllers/albumsController.js index 9c666be..55885f5 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -6,16 +6,16 @@ let albumsController = {} albumsController.list = function(req, res, next){ if(req.headers.auth !== config.adminToken) - return res.status(401).send('not-authorized') + return res.status(401).json({ success: false, description: 'not-authorized'}) let fields = ['id', 'name'] - if(req.headers.extended !== undefined) + if(req.params.sidebar === undefined) fields.push('timestamp') db.table('albums').select(fields).where('enabled', 1).then((albums) => { - if(req.headers.extended === undefined) + if(req.params.sidebar !== undefined) return res.json({ success: true, albums }) let ids = [] @@ -42,9 +42,9 @@ albumsController.list = function(req, res, next){ albumsController.create = function(req, res, next){ if(req.headers.auth !== config.adminToken) - return res.status(401).send('not-authorized') + return res.status(401).json({ success: false, description: 'not-authorized'}) - let name = req.headers.name + let name = req.body.name if(name === undefined || name === '') return res.json({ success: false, description: 'No album name specified' }) -- cgit v1.2.3