operators: make the terminal work
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user