operators: make the terminal work

This commit is contained in:
Girish Ramakrishnan
2021-09-21 18:27:54 -07:00
parent 6c9b8c8fa8
commit 06e5f9baa1
2 changed files with 1 additions and 18 deletions

View File

@@ -6,7 +6,6 @@ exports = module.exports = {
authorize,
authorizeOperator,
websocketAuth
};
const accesscontrol = require('../accesscontrol.js'),
@@ -92,22 +91,6 @@ function authorize(requiredRole) {
};
}
async function websocketAuth(requiredRole, req, res, next) {
assert.strictEqual(typeof requiredRole, 'string');
if (typeof req.query.access_token !== 'string') return next(new HttpError(401, 'access_token must be a string'));
const [error, user] = await safe(accesscontrol.verifyToken(req.query.access_token));
if (error && error.reason === BoxError.INVALID_CREDENTIALS) return next(new HttpError(401, error.message));
if (error) return next(new HttpError(500, error.message));
req.user = user;
if (users.compareRoles(req.user.role, requiredRole) < 0) return next(new HttpError(403, `role '${requiredRole}' is required but user has only '${user.role}'`));
next();
}
async function authorizeOperator(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
assert.strictEqual(typeof req.user, 'object');