diff --git a/O-BrandServer/obrand-server.js b/O-BrandServer/obrand-server.js index cbf4d24..1e788f8 100644 --- a/O-BrandServer/obrand-server.js +++ b/O-BrandServer/obrand-server.js @@ -32,6 +32,30 @@ app.use('/export',express.static(path.join(__dirname,'server/static'))); app.use('/css',express.static(path.join(__dirname,'server/css'))); app.use('/',express.static(path.join(__dirname,'wwwroot'))); +/* These next app.get's deal with ember's routing and when the user refreshes +the page. It forces the page back into the app. + */ +app.get('/about', function(request, response) { + response.redirect('/#/about'); +}); + +app.get('/profile', function(request, response) { + response.redirect('/#/profile'); +}); + +app.get('/company', function(request, response) { + response.redirect('/#/company'); +}); + +app.get('/venue', function(request, response) { + response.redirect('/#/venue'); +}); + +app.get('/pages', function(request, response) { + response.redirect('/#/pages'); +}); + + console.log(path.join(__dirname,'server/static')); var backend = globSync('./server/app/**/*.js', { cwd: __dirname }).map(require); diff --git a/O-BrandServer/server/app/pages.js b/O-BrandServer/server/app/pages.js index 589081b..42085a2 100644 --- a/O-BrandServer/server/app/pages.js +++ b/O-BrandServer/server/app/pages.js @@ -106,25 +106,30 @@ module.exports = function(app) { }); }); + pagesRouter.delete('/:id', function(req, res) { - logger.debug(req.params.id); - dbPages.deletePage(req.params.id) - .then(function(data) { + logger.debug('Delete...'); + if (/Bearer .+/.test(req.headers.authorization)) { + logger.debug(req.params.id); + dbPages.deletePage(req.params.id) + .then(function(data) { - let response = { - data: data - }; - res.status(200).send(response); - eventHandler.emit('renderPage', data.attributes); + let response = { + data: data + }; + res.status(200).send(response); - }) - .catch((err)=> { - console.error(err); - res.status(401).end(); - }); + }) + .catch((err)=> { + console.error(err); + res.status(401).end(); + }); + + } else { + res.status(401).end(); + } }); - pagesRouter.get('/:id', function(req, res) { logger.debug('Page to edit:', req.params.id);