apps: fix various operators issues

part of #791
This commit is contained in:
Girish Ramakrishnan
2021-09-21 17:28:58 -07:00
parent fabd0323e1
commit 6c9b8c8fa8
5 changed files with 19 additions and 18 deletions

View File

@@ -74,7 +74,10 @@ async function load(req, res, next) {
function getApp(req, res, next) {
assert.strictEqual(typeof req.app, 'object');
next(new HttpSuccess(200, apps.removeInternalFields(req.app)));
const result = apps.removeInternalFields(req.app);
result.accessLevel = apps.accessLevel(req.app, req.user);
next(new HttpSuccess(200, result));
}
async function listByUser(req, res, next) {
@@ -83,7 +86,11 @@ async function listByUser(req, res, next) {
let [error, result] = await safe(apps.listByUser(req.user));
if (error) return next(BoxError.toHttpError(error));
result = result.map(apps.removeRestrictedFields);
result = result.map(r => {
const app = apps.removeRestrictedFields(r);
app.accessLevel = apps.accessLevel(r, req.user);
return app;
});
next(new HttpSuccess(200, { apps: result }));
}