From 4619a143f536b0f320c15909ec614d19911067d9 Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Wed, 11 Dec 2013 19:46:56 -0800 Subject: [PATCH] Dont attempt access checking on models without a check access method --- lib/application.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/application.js b/lib/application.js index 8b32bb5f..73c09726 100644 --- a/lib/application.js +++ b/lib/application.js @@ -164,23 +164,27 @@ app.enableAuth = function() { var modelInstance = ctx.instance; var modelId = modelInstance && modelInstance.id || req.param('id'); - Model.checkAccess( - req.accessToken, - modelId, - method.name, - function(err, allowed) { - if(err) { - console.log(err); - next(err); - } else if(allowed) { - next(); - } else { - var e = new Error('Access Denied'); - e.statusCode = 401; - next(e); + if(Model.checkAccess) { + Model.checkAccess( + req.accessToken, + modelId, + method.name, + function(err, allowed) { + if(err) { + console.log(err); + next(err); + } else if(allowed) { + next(); + } else { + var e = new Error('Access Denied'); + e.statusCode = 401; + next(e); + } } - } - ); + ); + } else { + next(); + } }); }