mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
4f9b72ff43
- This is a minor bugbare, but it will affect some configuration I'm about to do for c8 - I've been wanting to do it for ages, middleware is plural all on it's own so it's an odd affectation in our codebase - This also only exists in 2 places, everywhere else we use "middleware" - Sadly it did result in a lot of churn as I did a full find and replace, but consistency is king!
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
const path = require('path');
|
|
const express = require('../../../../shared/express');
|
|
const middleware = require('./middleware');
|
|
const bodyParser = require('body-parser');
|
|
const routing = require('../../../services/routing');
|
|
const web = require('../../../../server/web');
|
|
const templateName = 'private';
|
|
const privateRouter = express.Router(templateName);
|
|
|
|
function _renderer(req, res) {
|
|
res.routerOptions = {
|
|
type: 'custom',
|
|
templates: templateName,
|
|
defaultTemplate: path.resolve(__dirname, 'views', `${templateName}.hbs`)
|
|
};
|
|
|
|
// Renderer begin
|
|
// Format data
|
|
let data = {};
|
|
|
|
if (res.error) {
|
|
data.error = res.error;
|
|
}
|
|
|
|
// Render Call
|
|
return routing.helpers.renderer(req, res, data);
|
|
}
|
|
|
|
// password-protected frontend route
|
|
privateRouter
|
|
.route('/')
|
|
.get(
|
|
middleware.redirectPrivateToHomeIfLoggedIn,
|
|
_renderer
|
|
)
|
|
.post(
|
|
bodyParser.urlencoded({extended: true}),
|
|
middleware.redirectPrivateToHomeIfLoggedIn,
|
|
web.shared.middleware.brute.privateBlog,
|
|
middleware.doLoginToPrivateSite,
|
|
_renderer
|
|
);
|
|
|
|
module.exports = privateRouter;
|
|
module.exports.renderer = _renderer;
|