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 @@
{error}
+[[global:400.message, {config.relative_path}]]
+ + + +[[error:goback]]
+