feat(query-params): proper handling in case of invalid credentials

This commit is contained in:
Benedikt Rötsch
2018-02-07 14:18:19 +01:00
committed by Benedikt Rötsch
parent ff305e7d34
commit 46074b508d
6 changed files with 147 additions and 71 deletions

View File

@@ -4,9 +4,6 @@
*/
const { initClients } = require('../services/contentful')
const { updateCookie } = require('./cookies')
const SETTINGS_NAME = 'theExampleAppSettings'
module.exports = async function settingsMiddleware (request, response, next) {
// Set default settings based on environment variables
@@ -28,7 +25,6 @@ module.exports = async function settingsMiddleware (request, response, next) {
deliveryToken: delivery_token,
previewToken: preview_token
}
updateCookie(response, SETTINGS_NAME, settings)
}
// Allow enabling and disabling of editorial features via query parameters
@@ -37,7 +33,6 @@ module.exports = async function settingsMiddleware (request, response, next) {
if (typeof editorial_features !== 'undefined') {
delete request.query.editorial_features
settings.editorialFeatures = editorial_features === 'enabled'
updateCookie(response, SETTINGS_NAME, settings)
}
/* eslint-enable camelcase */