mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
1181707a9d
closes #5914, #6589 - moves all private-blogging related code & tests into /server/apps/private-blogging/ - rework Grunt to run private-blogging tests - modify server apps code to have a place for internal apps
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
var path = require('path'),
|
|
express = require('express'),
|
|
middleware = require('./middleware'),
|
|
templates = require('../../../controllers/frontend/templates'),
|
|
setResponseContext = require('../../../controllers/frontend/context'),
|
|
privateRouter = express.Router();
|
|
|
|
function controller(req, res) {
|
|
var defaultView = path.resolve(__dirname, 'views', 'private.hbs'),
|
|
paths = templates.getActiveThemePaths(req.app.get('activeTheme')),
|
|
data = {};
|
|
|
|
if (res.error) {
|
|
data.error = res.error;
|
|
}
|
|
|
|
setResponseContext(req, res);
|
|
if (paths.hasOwnProperty('private.hbs')) {
|
|
return res.render('private', data);
|
|
} else {
|
|
return res.render(defaultView, data);
|
|
}
|
|
}
|
|
|
|
// password-protected frontend route
|
|
privateRouter.route('/')
|
|
.get(
|
|
middleware.isPrivateSessionAuth,
|
|
controller
|
|
)
|
|
.post(
|
|
middleware.isPrivateSessionAuth,
|
|
middleware.spamPrevention,
|
|
middleware.authenticateProtection,
|
|
controller
|
|
);
|
|
|
|
module.exports = privateRouter;
|
|
module.exports.controller = controller;
|