Node.js based forum software built for the modern web
fix: unable to register async method as response hook listener
Julian Lamdde5b6b81416
diff --git a/src/plugins/hooks.js b/src/plugins/hooks.jsindex f1c16f3f0f..48d2f53b9d 100644--- a/src/plugins/hooks.js+++ b/src/plugins/hooks.js@@ -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 sentif (params.res.headersSent) {- return next();+ return;}- hookObj.method(params);- next();+ await hookObj.method(params);});}diff --git a/src/routes/api.js b/src/routes/api.jsindex 93e96665fe..ba6e9b31e3 100644--- a/src/routes/api.js+++ b/src/routes/api.js@@ -8,7 +8,7 @@ module.exports = function (app, middleware, controllers) {var router = express.Router();app.use('/api', router);- router.get('/config', middleware.applyCSRF, controllers.api.getConfig);+ router.get('/config', middleware.applyCSRF, middleware.authenticateOrGuest, controllers.api.getConfig);router.get('/self', controllers.user.getCurrentUser);router.get('/user/uid/:uid', middleware.canViewUsers, controllers.user.getUserByUID);