fix: unable to register async method as response hook listener

Also fixes #8723, /api/config now runs middleware.authenticateOrGuest
This commit is contained in:
Julian Lam
2020-10-06 09:32:05 -04:00
parent b01bc2ae0f
commit dde5b6b814
2 changed files with 5 additions and 6 deletions

View File

@@ -189,21 +189,20 @@ module.exports = function (Plugins) {
if (!Array.isArray(hookList) || !hookList.length) {
return;
}
await async.eachSeries(hookList, function (hookObj, next) {
await async.eachSeries(hookList, async (hookObj) => {
if (typeof hookObj.method !== 'function') {
if (global.env === 'development') {
winston.warn('[plugins] Expected method for hook \'' + hook + '\' in plugin \'' + hookObj.id + '\' not found, skipping.');
}
return next();
return;
}
// Skip remaining hooks if headers have been sent
if (params.res.headersSent) {
return next();
return;
}
hookObj.method(params);
next();
await hookObj.method(params);
});
}