Pause the req before checking access

See https://github.com/strongloop/loopback-storage-service/issues/7
This commit is contained in:
Raymond Feng 2014-03-17 14:40:05 -07:00
parent f031e79392
commit 32a9131004
1 changed files with 5 additions and 0 deletions

View File

@ -279,11 +279,16 @@ app.enableAuth = function() {
var modelId = modelInstance && modelInstance.id || req.param('id');
if(Model.checkAccess) {
// Pause the request before checking access
// See https://github.com/strongloop/loopback-storage-service/issues/7
req.pause();
Model.checkAccess(
req.accessToken,
modelId,
method.name,
function(err, allowed) {
// Emit any cached data events that fired while checking access.
req.resume();
if(err) {
console.log(err);
next(err);