X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=otf-frontend%2Fserver%2Fsrc%2Ffeathers%2Fhooks%2Fpermissions%2Fpermissions.js;h=14e764ecc9eb0c7d8b4412d05f5e89f56127cd00;hb=cf067bb8bd9b45e79a85e9612a0f4c5abeb727b8;hp=3659bdea6c2e0870b4c1cbfd1aa2c6c5754aff7d;hpb=596b1d89c5f63170ed40abb6f7b9395178c5e44e;p=it%2Fotf.git diff --git a/otf-frontend/server/src/feathers/hooks/permissions/permissions.js b/otf-frontend/server/src/feathers/hooks/permissions/permissions.js index 3659bde..14e764e 100644 --- a/otf-frontend/server/src/feathers/hooks/permissions/permissions.js +++ b/otf-frontend/server/src/feathers/hooks/permissions/permissions.js @@ -140,22 +140,25 @@ permissions = function (name = null) { return context; } - const params = Object.assign({}, context.params, { provider: null }); + //see if the entity has already been pulled and stored, else get it + if(!context.params.entityData){ + const params = Object.assign({}, context.params, { provider: null }); + context.params.entityData = await service.get(context.id, params); + } - const result = await service.get(context.id, params); - throwUnlessCan(action, result); + throwUnlessCan(action, context.params.entityData); if (action === 'get') { - context.result = pick(result, allowedFields); + context.result = pick(context.params.entityData, allowedFields); }else{ if(context.data){ Object.keys(context.data).forEach(key => { if(key == "$push"){ Object.keys(context.data['$push']).forEach(k => { - throwUnlessCan(action, result, k); + throwUnlessCan(action, context.params.entityData, k); }); }else{ - throwUnlessCan(action, result, key); + throwUnlessCan(action, context.params.entityData, key); } }) }