Standard JS code conversion + fixes
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
'use strict'
|
||||
|
||||
var Promise = require('bluebird'),
|
||||
moment = require('moment-timezone');
|
||||
const moment = require('moment-timezone')
|
||||
|
||||
/**
|
||||
* Authentication middleware
|
||||
@@ -12,29 +11,27 @@ var Promise = require('bluebird'),
|
||||
* @return {any} void
|
||||
*/
|
||||
module.exports = (req, res, next) => {
|
||||
// Is user authenticated ?
|
||||
|
||||
// Is user authenticated ?
|
||||
if (!req.isAuthenticated()) {
|
||||
return res.redirect('/login')
|
||||
}
|
||||
|
||||
if (!req.isAuthenticated()) {
|
||||
return res.redirect('/login');
|
||||
}
|
||||
// Check permissions
|
||||
|
||||
// Check permissions
|
||||
if (!rights.check(req, 'read')) {
|
||||
return res.render('error-forbidden')
|
||||
}
|
||||
|
||||
if(!rights.check(req, 'read')) {
|
||||
return res.render('error-forbidden');
|
||||
}
|
||||
// Set i18n locale
|
||||
|
||||
// Set i18n locale
|
||||
req.i18n.changeLanguage(req.user.lang)
|
||||
res.locals.userMoment = moment
|
||||
res.locals.userMoment.locale(req.user.lang)
|
||||
|
||||
req.i18n.changeLanguage(req.user.lang);
|
||||
res.locals.userMoment = moment;
|
||||
res.locals.userMoment.locale(req.user.lang);
|
||||
// Expose user data
|
||||
|
||||
// Expose user data
|
||||
res.locals.user = req.user
|
||||
|
||||
res.locals.user = req.user;
|
||||
|
||||
return next();
|
||||
|
||||
};
|
||||
return next()
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Flash middleware
|
||||
@@ -9,9 +9,7 @@
|
||||
* @return {any} void
|
||||
*/
|
||||
module.exports = (req, res, next) => {
|
||||
res.locals.appflash = req.flash('alert')
|
||||
|
||||
res.locals.appflash = req.flash('alert');
|
||||
|
||||
next();
|
||||
|
||||
};
|
||||
next()
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Security Middleware
|
||||
*
|
||||
@@ -6,23 +8,21 @@
|
||||
* @param {Function} next next callback function
|
||||
* @return {any} void
|
||||
*/
|
||||
module.exports = function(req, res, next) {
|
||||
module.exports = function (req, res, next) {
|
||||
// -> Disable X-Powered-By
|
||||
app.disable('x-powered-by')
|
||||
|
||||
//-> Disable X-Powered-By
|
||||
app.disable('x-powered-by');
|
||||
// -> Disable Frame Embedding
|
||||
res.set('X-Frame-Options', 'deny')
|
||||
|
||||
//-> Disable Frame Embedding
|
||||
res.set('X-Frame-Options', 'deny');
|
||||
// -> Re-enable XSS Fitler if disabled
|
||||
res.set('X-XSS-Protection', '1; mode=block')
|
||||
|
||||
//-> Re-enable XSS Fitler if disabled
|
||||
res.set('X-XSS-Protection', '1; mode=block');
|
||||
// -> Disable MIME-sniffing
|
||||
res.set('X-Content-Type-Options', 'nosniff')
|
||||
|
||||
//-> Disable MIME-sniffing
|
||||
res.set('X-Content-Type-Options', 'nosniff');
|
||||
// -> Disable IE Compatibility Mode
|
||||
res.set('X-UA-Compatible', 'IE=edge')
|
||||
|
||||
//-> Disable IE Compatibility Mode
|
||||
res.set('X-UA-Compatible', 'IE=edge');
|
||||
|
||||
return next();
|
||||
|
||||
};
|
||||
return next()
|
||||
}
|
||||
|
Reference in New Issue
Block a user