mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: unable to register async method as response hook listener
Also fixes #8723, /api/config now runs middleware.authenticateOrGuest
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user