Dont attempt access checking on models without a check access method
This commit is contained in:
parent
0f4e9e1d1c
commit
4619a143f5
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue