Merge branch 'master' into develop

v1.18.x
Julian Lam 8 years ago
commit ab8d765f4f

@ -34,6 +34,15 @@ require('./maintenance')(middleware);
require('./user')(middleware);
require('./headers')(middleware);
middleware.stripLeadingSlashes = function (req, res, next) {
var target = req.originalUrl.replace(nconf.get('relative_path'), '');
if (target.startsWith('//')) {
res.redirect(nconf.get('relative_path') + target.replace(/^\/+/, '/'));
} else {
setImmediate(next);
}
};
middleware.pageView = function (req, res, next) {
analytics.pageView({
ip: req.ip,

@ -117,10 +117,10 @@ Plugins.reload = function (callback) {
Plugins.reloadRoutes = function (callback) {
var router = express.Router();
var ensureLoggedIn = require('connect-ensure-login');
// var ensureLoggedIn = require('connect-ensure-login');
router.all('(/api/admin|/api/admin/*?)', middleware.isAdmin);
router.all('(/admin|/admin/*?)', ensureLoggedIn.ensureLoggedIn(nconf.get('relative_path') + '/login?local=1'), middleware.applyCSRF, middleware.isAdmin);
// router.all('(/api/admin|/api/admin/*?)', middleware.isAdmin);
// router.all('(/admin|/admin/*?)', ensureLoggedIn.ensureLoggedIn(nconf.get('relative_path') + '/login?local=1'), middleware.applyCSRF, middleware.isAdmin);
router.hotswapId = 'plugins';
router.render = function () {

@ -115,13 +115,11 @@ module.exports = function (app, middleware, hotswapIds, callback) {
pluginRouter.hotswapId = 'plugins';
authRouter.hotswapId = 'auth';
app.all(relativePath + '(/api|/api/*?)', middleware.prepareAPI);
app.all(relativePath + '(/+api|/+api/*?)', middleware.prepareAPI);
app.all(relativePath + '(/+api/admin|/+api/admin/*?)', middleware.isAdmin);
app.all(relativePath + '(/+admin|/+admin/*?)', ensureLoggedIn.ensureLoggedIn(nconf.get('relative_path') + '/login?local=1'), middleware.applyCSRF, middleware.isAdmin);
app.all(relativePath + '(/api/admin|/api/admin/*?)', middleware.isAdmin);
app.all(relativePath + '(/admin|/admin/*?)', ensureLoggedIn.ensureLoggedIn(nconf.get('relative_path') + '/login?local=1'), middleware.applyCSRF, middleware.isAdmin);
router.all('(/api/admin|/api/admin/*?)', middleware.isAdmin);
router.all('(/admin|/admin/*?)', ensureLoggedIn.ensureLoggedIn(nconf.get('relative_path') + '/login?local=1'), middleware.applyCSRF, middleware.isAdmin);
app.use(middleware.stripLeadingSlashes);
adminRoutes(router, middleware, controllers);
metaRoutes(router, middleware, controllers);
@ -140,7 +138,7 @@ module.exports = function (app, middleware, hotswapIds, callback) {
groupRoutes(router, middleware, controllers);
for (x = 0; x < routers.length; x += 1) {
app.use(relativePath, routers[x]);
app.use(relativePath || '/', routers[x]);
}
if (process.env.NODE_ENV === 'development') {

Loading…
Cancel
Save