From 85ee22a79bcbbb1995106f43d4c74d6ba9206cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Zanghelini?= Date: Sun, 2 Jul 2017 17:46:07 -0300 Subject: [PATCH] Remove useless next calls --- src/controllers/helpers.js | 4 ++++ src/controllers/index.js | 6 ++---- src/views/400.tpl | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 3057aa5265..b936bf3f8d 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -15,6 +15,10 @@ var middleware = require('../middleware'); var helpers = module.exports; helpers.noScriptErrors = function (req, res, error, httpStatus) { + if (req.body.noscript !== 'true') { + return res.status(httpStatus).send(error); + } + var middleware = require('../middleware'); var httpStatusString = httpStatus.toString(); middleware.buildHeader(req, res, function () { diff --git a/src/controllers/index.js b/src/controllers/index.js index 468f0b9d21..f9d7ad18c2 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -301,14 +301,13 @@ Controllers.composePost = function (req, res, next) { topics.reply(data, next); }, function (postData, next) { - next(null, postData); - user.updateOnlineUsers(postData.uid); res.redirect(nconf.get('relative_path') + '/post/' + postData.pid); }, ], function (err) { if (err) { + req.body.noscript = 'true'; return helpers.noScriptErrors(req, res, err.message, 400); } next(err); @@ -324,12 +323,11 @@ Controllers.composePost = function (req, res, next) { topics.post(data, next); }, function (result, next) { - next(null, result.topicData); - res.redirect(nconf.get('relative_path') + '/topic/' + result.topicData.slug); }, ], function (err) { if (err) { + req.body.noscript = 'true'; return helpers.noScriptErrors(req, res, err.message, 400); } next(err); diff --git a/src/views/400.tpl b/src/views/400.tpl index 9c263fcff1..c36f1b2f48 100644 --- a/src/views/400.tpl +++ b/src/views/400.tpl @@ -1,4 +1,12 @@
[[global:400.title]] + +

{error}

+

[[global:400.message, {config.relative_path}]]

+ + + +

[[error:goback]]

+