Removed res.isAdmin from admin express app (#9889)

refs #9866

- the admin express app serves the client
- it only uses admin redirects
- we can use the new middleware function to avoid `res.isAdmin`
This commit is contained in:
Katharina Irrgang 2018-09-20 21:38:09 +02:00 committed by Rishabh Garg
parent fcd275f6c0
commit 0d35733448

View File

@ -13,7 +13,7 @@ const serveStatic = require('express').static;
// Global/shared middleware
const cacheControl = require('../shared/middlewares/cache-control');
const urlRedirects = require('../shared/middlewares/url-redirects');
const {adminRedirect} = require('../shared/middlewares/url-redirects');
const errorHandler = require('../shared/middlewares/error-handler');
const maintenance = require('../shared/middlewares/maintenance');
const prettyURLs = require('../shared/middlewares/pretty-urls');
@ -22,13 +22,6 @@ module.exports = function setupAdminApp() {
debug('Admin setup start');
const adminApp = express();
// First determine whether we're serving admin or theme content
// @TODO finish refactoring this away.
adminApp.use(function setIsAdmin(req, res, next) {
res.isAdmin = true;
next();
});
// Admin assets
// @TODO ensure this gets a local 404 error handler
const configMaxAge = config.get('caching:admin:maxAge');
@ -52,7 +45,7 @@ module.exports = function setupAdminApp() {
// Force SSL if required
// must happen AFTER asset loading and BEFORE routing
adminApp.use(urlRedirects);
adminApp.use(adminRedirect);
// Add in all trailing slashes & remove uppercase
// must happen AFTER asset loading and BEFORE routing