mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +03:00
4237446277
no issue - Consistent naming for postLookup - makes it easier to search and inspect the various usages - Cleanup unneeded code - Make res.render calls more consistent - add some consistency to the calls to res.render - Remove ancient reference to dataProvider - Let's call it models everywhere now... - Use consistent formatting across the API - we're no longer using alignment in vars - Misc other consistency changes in API - always refer to local utils as apiUtils - logical grouping of requires - dependencies, utils, "lib common" etc - use xAPI to refer to API endpoints, e.g. mailAPI, settingsAPI for clarity
42 lines
1.2 KiB
JavaScript
42 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'),
|
|
view = templates.pickTemplate(templateName, defaultTemplate),
|
|
data = {};
|
|
|
|
if (res.error) {
|
|
data.error = res.error;
|
|
}
|
|
|
|
setResponseContext(req, res);
|
|
|
|
return res.render(view, 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;
|