diff --git a/src/controllers/404.js b/src/controllers/404.js index adcc9f68a8..550f7b1785 100644 --- a/src/controllers/404.js +++ b/src/controllers/404.js @@ -7,7 +7,7 @@ var validator = require('validator'); var meta = require('../meta'); var plugins = require('../plugins'); -exports.handle404 = function (req, res) { +exports.handle404 = function handle404(req, res) { var relativePath = nconf.get('relative_path'); var isClientScript = new RegExp('^' + relativePath + '\\/assets\\/src\\/.+\\.js'); diff --git a/src/controllers/errors.js b/src/controllers/errors.js index 0887de8c9b..849750e391 100644 --- a/src/controllers/errors.js +++ b/src/controllers/errors.js @@ -5,7 +5,7 @@ var winston = require('winston'); var validator = require('validator'); var plugins = require('../plugins'); -exports.handleURIErrors = function (err, req, res, next) { +exports.handleURIErrors = function handleURIErrors(err, req, res, next) { // Handle cases where malformed URIs are passed in if (err instanceof URIError) { const cleanPath = req.path.replace(new RegExp('^' + nconf.get('relative_path')), ''); @@ -36,7 +36,7 @@ exports.handleURIErrors = function (err, req, res, next) { // this needs to have four arguments or express treats it as `(req, res, next)` // don't remove `next`! -exports.handleErrors = function (err, req, res, next) { // eslint-disable-line no-unused-vars +exports.handleErrors = function handleErrors(err, req, res, next) { // eslint-disable-line no-unused-vars var cases = { EBADCSRFTOKEN: function () { winston.error(req.path + '\n', err.message); diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 0068e389b4..5f300bc397 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -14,8 +14,14 @@ var loginStrategies = []; var Auth = module.exports; Auth.initialize = function (app, middleware) { - app.use(passport.initialize()); - app.use(passport.session()); + const passwortInitMiddleware = passport.initialize(); + app.use(function passportInitialize(req, res, next) { + passwortInitMiddleware(req, res, next); + }); + const passportSessionMiddleware = passport.session(); + app.use(function passportSession(req, res, next) { + passportSessionMiddleware(req, res, next); + }); app.use(Auth.setAuthVars); @@ -23,7 +29,7 @@ Auth.initialize = function (app, middleware) { Auth.middleware = middleware; }; -Auth.setAuthVars = function (req, res, next) { +Auth.setAuthVars = function setAuthVars(req, res, next) { var isSpider = req.isSpider(); req.loggedIn = !isSpider && !!req.user; if (req.user) { diff --git a/src/webserver.js b/src/webserver.js index 1f2477ff88..bdf2e1cd4f 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -166,8 +166,14 @@ function setupExpressApp(app, callback) { app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.use(cookieParser()); - app.use(useragent.express()); - app.use(detector.middleware()); + const userAgentMiddleware = useragent.express(); + app.use(function userAgent(req, res, next) { + userAgentMiddleware(req, res, next); + }); + const spiderDetectorMiddleware = detector.middleware(); + app.use(function spiderDetector(req, res, next) { + spiderDetectorMiddleware(req, res, next); + }); app.use(session({ store: db.sessionStore,