mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 16:42:17 +03:00
bb3cc8c0f8
closes #8082 - Update the `pickTemplate` logic to a) rely on getActive().hasTemplate() instead of being passed a list of paths b) support the concept of a fallback, which is returned if there is no theme, or if the theme doesn't have a more specific template - Update every instance of template picking, across the 3 internalApps, and render-channel, to use this new logic - update the tests
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
var path = require('path'),
|
|
express = require('express'),
|
|
middleware = require('./middleware'),
|
|
bodyParser = require('body-parser'),
|
|
templates = require('../../../controllers/frontend/templates'),
|
|
setResponseContext = require('../../../controllers/frontend/context'),
|
|
brute = require('../../../middleware/brute'),
|
|
|
|
privateRouter = express.Router();
|
|
|
|
function controller(req, res) {
|
|
var templateName = 'private',
|
|
defaultTemplate = path.resolve(__dirname, 'views', templateName + '.hbs'),
|
|
data = {};
|
|
|
|
if (res.error) {
|
|
data.error = res.error;
|
|
}
|
|
|
|
setResponseContext(req, res);
|
|
|
|
return res.render(templates.pickTemplate(templateName, defaultTemplate), data);
|
|
}
|
|
|
|
// password-protected frontend route
|
|
privateRouter.route('/')
|
|
.get(
|
|
middleware.isPrivateSessionAuth,
|
|
controller
|
|
)
|
|
.post(
|
|
bodyParser.urlencoded({extended: true}),
|
|
middleware.isPrivateSessionAuth,
|
|
brute.privateBlog,
|
|
middleware.authenticateProtection,
|
|
controller
|
|
);
|
|
|
|
module.exports = privateRouter;
|
|
module.exports.controller = controller;
|