Skip to content

Commit

Permalink
fix: move call to filter:middleware.buildHeader out of parallel so …
Browse files Browse the repository at this point in the history
…that req can be overridden by plugins prior to loading config
  • Loading branch information
julianlam committed Jan 13, 2023
1 parent d17d4ec commit 25ae58e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/middleware/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ middleware.buildHeader = helpers.try(async (req, res, next) => {
if (req.method === 'GET') {
await require('./index').applyCSRFasync(req, res);
}

({ req, locals: res.locals } = await plugins.hooks.fire('filter:middleware.buildHeader', { req: req, locals: res.locals }));
const [config, canLoginIfBanned] = await Promise.all([
controllers.api.loadConfig(req),
user.bans.canLoginIfBanned(req.uid),
plugins.hooks.fire('filter:middleware.buildHeader', { req: req, locals: res.locals }),
]);

if (!canLoginIfBanned && req.loggedIn) {
Expand Down

0 comments on commit 25ae58e

Please sign in to comment.