ee-soa-service
Advanced tools
Comparing version 0.2.33 to 0.2.34
@@ -212,18 +212,25 @@ | ||
this.permissionManager.getPermission(req.accessTokens || []).then(function(permission) { | ||
try { | ||
// check permissions, go through or return an error | ||
if (permission.isActionAllowed(this.name+'.'+collection, action)) { | ||
// check permissions, go through or return an error | ||
if (permission.isActionAllowed(this.name+'.'+collection, action)) { | ||
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - access was granted!'); | ||
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), req.getActionName()].join('.')+' - access was granted!'); | ||
// store the permissions object on the request | ||
req.permissions = permission; | ||
// store the permissions object on the request | ||
req.permissions = permission; | ||
// go :) | ||
this._executeRequest(collection, action, req, callback); | ||
// go :) | ||
this._executeRequest(collection, action, req, callback); | ||
} | ||
else { | ||
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), action].join('.')+' - access was denied! tokens: '+(req.accessTokens || []).join(', ')); | ||
this._handleResponse(new Error('You [the user(s) '+permission.getUsers().map(function(u) {return u.id}).join(', ')+' and the service(s) '+permission.getServices().map(function(s) {return s.identifier}).join(', ')+'] are not allowed to access the controller «'+collection+'», action «'+(action)+'» on the service «'+this.name+'»!'), null, req, callback, SOAResponse.statusCodes.ACCESS_UNAUTHORIZED); | ||
} | ||
} | ||
else { | ||
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), action].join('.')+' - access was denied! tokens: '+(req.accessTokens || []).join(', ')); | ||
catch (err) { | ||
if (debugService) log.info('[DefaultService] '+[this.name, req.getCollection(), action].join('.')+' threw an error: '+err); | ||
callback(new Error('You [the user(s) '+permission.getUsers().map(function(u) {return u.id}).join(', ')+' and the service(s) '+permission.getServices().map(function(s) {return s.identifier}).join(', ')+'] are not allowed to access the controller «'+collection+'», action «'+(action)+'» on the service «'+this.name+'»!'), {}, SOAResponse.statusCodes.ACCESS_UNAUTHORIZED); | ||
this._handleResponse(new Error('The controller «'+collection+'», action «'+(action)+'» threw an error on the service «'+this.name+'»: '+e), null, req, callback, SOAResponse.statusCodes.SERVICE_EXCEPTION); | ||
} | ||
@@ -234,3 +241,3 @@ }.bind(this)).catch(function(err) { | ||
// failed to load the permissions | ||
callback(new Error('Failed to load the permissions for the controller «'+collection+'», action «'+(action)+'» on the service «'+this.name+'»: '+err), {}, SOAResponse.statusCodes.SERVICE_EXCEPTION); | ||
this._handleResponse(new Error('Failed to load the permissions for the controller «'+collection+'», action «'+(action)+'» on the service «'+this.name+'»: '+err), null, req, callback, SOAResponse.statusCodes.SERVICE_EXCEPTION); | ||
}.bind(this)); | ||
@@ -242,3 +249,3 @@ } | ||
} | ||
else callback(new Error(collection + " not found in service " + this.name)); | ||
else this._handleResponse(new Error(collection + " not found in service " + this.name), {}, req, callback); | ||
} | ||
@@ -245,0 +252,0 @@ |
@@ -5,3 +5,3 @@ { | ||
, "keywords" : ["ee", "soa", "service"] | ||
, "version" : "0.2.33" | ||
, "version" : "0.2.34" | ||
, "author": { | ||
@@ -8,0 +8,0 @@ "name" : "Tobias Kneubuehler" |
82353
1382