feat(credentials): allow setting of space id and tokens via query string

This commit is contained in:
Benedikt Rötsch
2017-09-29 10:50:31 +02:00
committed by Benedikt Rötsch
parent 9806d494dc
commit 926b59aaaa
2 changed files with 26 additions and 7 deletions

15
app.js
View File

@@ -37,6 +37,17 @@ app.use(function (req, res, next) {
res.locals.query = req.query
res.locals.currentPath = req.path
console.log(req.path)
// Allow setting of credentials via query parameters
const { space_id, preview_access_token, delivery_access_token } = req.query
if (space_id && preview_access_token && delivery_access_token) { // eslint-disable-line camelcase
const settings = {space: space_id, cda: delivery_access_token, cpa: preview_access_token}
res.cookie('universitySettings', settings, { maxAge: 900000, httpOnly: true })
initClient(settings)
} else {
initClient(req.cookies.universitySettings)
}
next()
})
@@ -65,8 +76,4 @@ app.use(function (err, req, res, next) {
res.render('error')
})
// app.use()
// init the contentful client
initClient()
module.exports = app