Start using req.resources = { app, volume, ...} pattern
Reason was that req.app was clashing with expressjs v5 which stores the main expressjs app object there
This commit is contained in:
@@ -90,11 +90,11 @@ function authorize(requiredRole) {
|
||||
async function authorizeOperator(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
assert.strictEqual(typeof req.user, 'object');
|
||||
assert.strictEqual(typeof req.app, 'object');
|
||||
assert.strictEqual(typeof req.resources.app, 'object');
|
||||
assert.strictEqual(typeof req.token, 'object');
|
||||
|
||||
if (!tokens.hasScope(req.token, req.method, req.path)) return next(new HttpError(403, 'access token does not have this scope'));
|
||||
if (apps.isOperator(req.app, req.user)) return next();
|
||||
if (apps.isOperator(req.resources.app, req.user)) return next();
|
||||
|
||||
return next(new HttpError(403, 'user is not an operator'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user