Skip to content

Commit baf4a59

Browse files
committed
Modular: fixes bug — rateLimiterReward was not awaited
1 parent 069f3cd commit baf4a59

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/appFactory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ module.exports = async function ({ hostIdentity, jwtSecret, accountMgr, storeRou
144144

145145
app.use([`${basePath}/`, `${basePath}/oauth`, `${basePath}/account`, `${basePath}/admin`], memorySession);
146146

147-
app.use((req, _res, next) => {
147+
app.use(async (req, _res, next) => {
148148
if (req.session?.privileges?.STORE) {
149149
// refunds the points consumed by rate-limiting middleware
150-
rateLimiterReward(req.ip, POINTS_UNAUTH_REQUEST - POINTS_AUTH_REQUEST);
150+
await rateLimiterReward(req.ip, POINTS_UNAUTH_REQUEST - POINTS_AUTH_REQUEST);
151151
}
152152
next();
153153
});

lib/routes/storage_common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ module.exports = function (hostIdentity, jwtSecret) {
149149
return [requiredScopeName, '*'].includes(grantedParts[0]) && grantedParts[1].startsWith(requiredPermission);
150150
})) {
151151
// refunds the points consumed by rate-limiter middleware
152-
rateLimiterReward(req.ip, POINTS_UNAUTH_REQUEST - POINTS_AUTH_REQUEST);
152+
await rateLimiterReward(req.ip, POINTS_UNAUTH_REQUEST - POINTS_AUTH_REQUEST);
153153
next();
154154
} else {
155155
return unauthorized(req, res, 403, 'insufficient_scope', requiredScope, `user has permissions '${grantedScopes}' but lacks '${requiredScope}'`);

0 commit comments

Comments
 (0)