mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
parent
4f22a402a3
commit
4b3f3b8d0f
4 changed files with 21 additions and 21 deletions
|
@ -1,14 +1,13 @@
|
|||
var urlService = require('../../services/url'),
|
||||
const urlService = require('../../services/url'),
|
||||
common = require('../../lib/common'),
|
||||
middleware = require('./lib/middleware'),
|
||||
router = require('./lib/router'),
|
||||
registerHelpers = require('./lib/helpers'),
|
||||
// routeKeywords.private: 'private'
|
||||
PRIVATE_KEYWORD = 'private',
|
||||
checkSubdir;
|
||||
PRIVATE_KEYWORD = 'private';
|
||||
|
||||
checkSubdir = function checkSubdir() {
|
||||
var paths;
|
||||
let checkSubdir = function checkSubdir() {
|
||||
let paths = '';
|
||||
|
||||
if (urlService.utils.getSubdir()) {
|
||||
paths = urlService.utils.getSubdir().split('/');
|
||||
|
@ -28,7 +27,7 @@ checkSubdir = function checkSubdir() {
|
|||
|
||||
module.exports = {
|
||||
activate: function activate(ghost) {
|
||||
var privateRoute = '/' + PRIVATE_KEYWORD + '/';
|
||||
let privateRoute = `/${PRIVATE_KEYWORD}/`;
|
||||
|
||||
checkSubdir();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Password input used on private.hbs for password-protected blogs
|
||||
|
||||
// (less) dirty requires
|
||||
var proxy = require('../../../../helpers/proxy'),
|
||||
const proxy = require('../../../../helpers/proxy'),
|
||||
SafeString = proxy.SafeString,
|
||||
templates = proxy.templates;
|
||||
|
||||
|
@ -13,19 +13,19 @@ module.exports = function input_password(options) { // eslint-disable-line camel
|
|||
options = options || {};
|
||||
options.hash = options.hash || {};
|
||||
|
||||
var className = (options.hash.class) ? options.hash.class : 'private-login-password',
|
||||
let className = (options.hash.class) ? options.hash.class : 'private-login-password',
|
||||
extras = 'autofocus="autofocus"',
|
||||
output;
|
||||
|
||||
if (options.hash.placeholder) {
|
||||
extras += ' placeholder="' + options.hash.placeholder + '"';
|
||||
extras += ` placeholder="${options.hash.placeholder}"`;
|
||||
}
|
||||
|
||||
output = templates.input({
|
||||
type: 'password',
|
||||
name: 'password',
|
||||
className: className,
|
||||
extras: extras
|
||||
className,
|
||||
extras
|
||||
});
|
||||
|
||||
return new SafeString(output);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var fs = require('fs-extra'),
|
||||
const fs = require('fs-extra'),
|
||||
session = require('cookie-session'),
|
||||
crypto = require('crypto'),
|
||||
path = require('path'),
|
||||
|
@ -8,22 +8,23 @@ var fs = require('fs-extra'),
|
|||
common = require('../../../lib/common'),
|
||||
settingsCache = require('../../../services/settings/cache'),
|
||||
// routeKeywords.private: 'private'
|
||||
privateRoute = '/private/',
|
||||
privateBlogging;
|
||||
privateRoute = '/private/';
|
||||
|
||||
let privateBlogging = null;
|
||||
|
||||
function verifySessionHash(salt, hash) {
|
||||
if (!salt || !hash) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var hasher = crypto.createHash('sha256');
|
||||
let hasher = crypto.createHash('sha256');
|
||||
hasher.update(settingsCache.get('password') + salt, 'utf8');
|
||||
return hasher.digest('hex') === hash;
|
||||
}
|
||||
|
||||
privateBlogging = {
|
||||
checkIsPrivate: function checkIsPrivate(req, res, next) {
|
||||
var isPrivateBlog = settingsCache.get('is_private');
|
||||
let isPrivateBlog = settingsCache.get('is_private');
|
||||
|
||||
if (!isPrivateBlog) {
|
||||
res.isPrivateBlog = false;
|
||||
|
@ -81,7 +82,7 @@ privateBlogging = {
|
|||
},
|
||||
|
||||
authenticatePrivateSession: function authenticatePrivateSession(req, res, next) {
|
||||
var hash = req.session.token || '',
|
||||
let hash = req.session.token || '',
|
||||
salt = req.session.salt || '',
|
||||
isVerified = verifySessionHash(salt, hash),
|
||||
url;
|
||||
|
@ -101,7 +102,7 @@ privateBlogging = {
|
|||
return res.redirect(urlService.utils.urlFor('home', true));
|
||||
}
|
||||
|
||||
var hash = req.session.token || '',
|
||||
let hash = req.session.token || '',
|
||||
salt = req.session.salt || '',
|
||||
isVerified = verifySessionHash(salt, hash);
|
||||
|
||||
|
@ -119,7 +120,7 @@ privateBlogging = {
|
|||
return next();
|
||||
}
|
||||
|
||||
var bodyPass = req.body.password,
|
||||
let bodyPass = req.body.password,
|
||||
pass = settingsCache.get('password'),
|
||||
hasher = crypto.createHash('sha256'),
|
||||
salt = Date.now().toString(),
|
||||
|
|
|
@ -11,12 +11,12 @@ function _renderer(req, res) {
|
|||
res.routerOptions = {
|
||||
type: 'custom',
|
||||
templates: templateName,
|
||||
defaultTemplate: path.resolve(__dirname, 'views', templateName + '.hbs')
|
||||
defaultTemplate: path.resolve(__dirname, 'views', `${templateName}.hbs`)
|
||||
};
|
||||
|
||||
// Renderer begin
|
||||
// Format data
|
||||
var data = {};
|
||||
let data = {};
|
||||
|
||||
if (res.error) {
|
||||
data.error = res.error;
|
||||
|
|
Loading…
Add table
Reference in a new issue