0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00

Fixed broken routes with members serverside rendering

no issue

refs cc1f62438d
This commit is contained in:
Rish 2019-02-26 11:59:21 +07:00
parent 897247978b
commit b010c1be7e
2 changed files with 17 additions and 8 deletions

View file

@ -1,8 +1,9 @@
const _ = require('lodash'),
Promise = require('bluebird'),
url = require('url'),
debug = require('ghost-ignition').debug('services:routing:helpers:entry-lookup'),
routeMatch = require('path-match')();
const _ = require('lodash');
const Promise = require('bluebird');
const url = require('url');
const debug = require('ghost-ignition').debug('services:routing:helpers:entry-lookup');
const routeMatch = require('path-match')();
const config = require('../../../config');
function entryLookup(postUrl, routerOptions, locals) {
debug(postUrl);
@ -35,8 +36,14 @@ function entryLookup(postUrl, routerOptions, locals) {
* Query database to find entry.
* @deprecated: `author`, will be removed in Ghost 3.0
*/
let options = {
include: 'author,authors,tags'
};
if (config.get('enableDeveloperExperiments')) {
options.context = {member: locals.member};
}
return api[routerOptions.query.controller]
.read(_.extend(_.pick(params, 'slug', 'id'), {include: 'author,authors,tags', context: {member: locals.member}}))
.read(_.extend(_.pick(params, 'slug', 'id'), options))
.then(function then(result) {
const entry = result[routerOptions.query.resource][0];

View file

@ -4,6 +4,7 @@
*/
const _ = require('lodash');
const Promise = require('bluebird');
const config = require('../../../config');
// The default settings for a default post query
const queryDefaults = {
@ -50,8 +51,9 @@ function processQuery(query, slugParam, locals) {
query.options[name] = _.isString(option) ? option.replace(/%s/g, slugParam) : option;
});
query.options.context = {member: locals.member};
if (config.get('enableDeveloperExperiments')) {
query.options.context = {member: locals.member};
}
// Return a promise for the api query
return api[query.controller][query.type](query.options);
}