feat: more naming

v1.18.x
Barış Soner Uşaklı 6 years ago
parent f88db22ca2
commit ae0fe5e880

@ -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');

@ -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);

@ -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) {

@ -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,

Loading…
Cancel
Save