express: Move up `cookie-parser` middleware

This makes it possible for the `preAuthorize` and `preExpressSession`
hooks to easily read or set cookies.
pull/5358/head
Richard Hansen 2022-01-12 18:29:29 -05:00
parent ab85db4426
commit 75637708c0
1 changed files with 2 additions and 1 deletions

View File

@ -170,6 +170,8 @@ exports.restartServer = async () => {
})); }));
} }
app.use(cookieParser(settings.sessionKey, {}));
exports.sessionMiddleware = expressSession({ exports.sessionMiddleware = expressSession({
secret: settings.sessionKey, secret: settings.sessionKey,
store: new SessionStore(), store: new SessionStore(),
@ -212,7 +214,6 @@ exports.restartServer = async () => {
// call `next('route')` which will skip the remaining middlewares in this list. // call `next('route')` which will skip the remaining middlewares in this list.
webaccess.nextRouteIfPreAuthorized, webaccess.nextRouteIfPreAuthorized,
exports.sessionMiddleware, exports.sessionMiddleware,
cookieParser(settings.sessionKey, {}),
webaccess.checkAccess, webaccess.checkAccess,
]); ]);