forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved fetching client out of our
ghost_head
helper (TryGhost#9180)
refs TryGhost#8995 - move the getClient lookup from ghost_head into middleware - use res.locals to keep track of the information (res.locals.client) - make the middleware global to all frontend routes - ghost_head: get locals from options.data not this (!) - adapt lot's of tests
- Loading branch information
Showing
5 changed files
with
755 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var api = require('../api'), | ||
labs = require('../utils/labs'), | ||
logging = require('../logging'); | ||
|
||
module.exports = function getFrontendClient(req, res, next) { | ||
if (labs.isSet('publicAPI') !== true) { | ||
return next(); | ||
} | ||
|
||
return api.clients | ||
.read({slug: 'ghost-frontend'}) | ||
.then(function handleClient(client) { | ||
client = client.clients[0]; | ||
|
||
if (client.status === 'enabled') { | ||
res.locals.client = { | ||
id: client.slug, | ||
secret: client.secret | ||
}; | ||
} | ||
|
||
next(); | ||
}) | ||
.catch(function (err) { | ||
// Log the error, but carry on as this is non-critical | ||
logging.error(err); | ||
next(); | ||
}); | ||
}; |
Oops, something went wrong.