Skip to content

Commit

Permalink
Updated github links
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsee committed Jan 14, 2019
2 parents c8132b8 + 2ec9136 commit 6c22b6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
36 changes: 13 additions & 23 deletions common/models/framework/data-ACL.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var loopback = require('loopback');
var applyFilter = require('loopback-filters');
var mergeQuery = require('loopback-datasource-juggler/lib/utils').mergeQuery;
var async = require('async');

var loopbackAccessContext = require('loopback/lib/access-context');
var AccessContext = loopbackAccessContext.AccessContext;
var errorUtil = require('../../../lib/common/error-utils').getValidationError;
Expand All @@ -51,17 +50,6 @@ function getValue(target, field) {
return retVal;
}


// function hasBody(accepts) {
// for (var i = 0; i < accepts.length; i++) {
// var arg = accepts[i];
// if (arg.http && arg.http.source === 'body') {
// return true;
// }
// }
// return false;
// }

function buildFilter(filter, ctx) {
Object.keys(filter).map(function filterForEachKey(item) {
var value = filter[item];
Expand All @@ -74,7 +62,7 @@ function buildFilter(filter, ctx) {
throw err;
}
} else if (value.startsWith('@CC.')) {
filter[item] = getValue(ctx, value.substr(5));
filter[item] = getValue(ctx, value.substr(4));
if (!filter[item]) {
var err1 = new Error('Context not present');
err1.retriable = false;
Expand Down Expand Up @@ -182,9 +170,7 @@ module.exports = function DataACLFn(DataACL) {

async.parallel(inRoleTasks, function inRoleTasks(err, results) {
if (err) {
if (callback) {
return callback(err, null);
}
return callback(err, null);
}

var filterUsed = (dataFilter[1] && Object.keys(dataFilter[1]).length) ? dataFilter[1] : dataFilter[0];
Expand All @@ -195,17 +181,20 @@ module.exports = function DataACLFn(DataACL) {
}

var obj = {};
var callContext = ctx.req.callContext;
var callContext = ctx.req.callContext || {};
try {
buildFilter(filterUsed, callContext.ctx);
} catch (err) {
// do not fetch any record instead of error
// TODO more analysis best way to handle this
// fix for demo today
filterUsed = { 'ahfgfhewklhkhwakwd': 'asdasdsad' };
var error = new Error();
error.name = 'DataACL Definition Error';
error.message = `The DataACL defined is invalid for model ${modelName} `;
error.code = 'DATA_ACL_ERROR_090';
error.type = 'value in context is missing';
log.error(log.defaultContext(), 'DataACL filter error', error);
return callback(error);
}
var filter = ctx.args.filter || {};
if (typeof ctx.args.filter === 'string') {
if (typeof filter === 'string') {
filter = JSON.parse(filter);
}

Expand Down Expand Up @@ -246,7 +235,7 @@ module.exports = function DataACLFn(DataACL) {
}
}

var updateMethods = ['create', 'updateAttributes', 'update', 'updateOrCreate', 'upsert'];
var updateMethods = ['create', 'updateAttributes', 'update', 'updateOrCreate', 'upsert', 'replaceById', 'replaceOrCreate'];
var applyDataACLOnBody = updateMethods.indexOf(method.name) >= 0 || method.applyDataACLOnBody;
// Only if this method is for parent model
// and only for those methods which accepts body
Expand Down Expand Up @@ -276,6 +265,7 @@ module.exports = function DataACLFn(DataACL) {
obj.options = callContext;
errorUtil(errorCode, obj, function errorUtil(err) {
err.statusCode = 403;
log.error(log.defaultContext(), 'Data Access Control does not allow access', err);
return callback(err, failed);
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oe-cloud",
"version": "1.6.0",
"version": "1.7.0",
"main": "server/server.js",
"engines": {
"node": ">=6.9.0"
Expand Down
6 changes: 3 additions & 3 deletions test/instance-caching-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ describe('Instance Caching Test', function () {
});
});

it('Should cache the Test instance after upsert', function (done) {
xit('Should cache the Test instance after upsert', function (done) {
var id = uuidv4();
var result1, result2;
TestModel.create({
Expand Down Expand Up @@ -490,7 +490,7 @@ describe('Instance Caching Test', function () {
});
});

it('Should cache the Test instance after save', function (done) {
xit('Should cache the Test instance after save', function (done) {
var id = uuidv4();
var result1, result2;
TestModel.create({
Expand Down Expand Up @@ -532,7 +532,7 @@ describe('Instance Caching Test', function () {
});
});

it('Should cache the Test instance after updateAttributes', function (done) {
xit('Should cache the Test instance after updateAttributes', function (done) {
var id = uuidv4();
var result1, result2;
TestModel.create({
Expand Down

0 comments on commit 6c22b6a

Please sign in to comment.