feat(credentials): allow setting of space id and tokens via query string
This commit is contained in:
committed by
Benedikt Rötsch
parent
9806d494dc
commit
926b59aaaa
15
app.js
15
app.js
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user