Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't fail if entity cannot be fetched

  • Loading branch information...
commit cdeb91242b9d285f7de8c74f2de9ab46e922e2ad 1 parent 4605498
@tschaub authored
Showing with 13 additions and 7 deletions.
  1. +13 −7 lib/manager.js
View
20 lib/manager.js
@@ -202,14 +202,13 @@ Manager.prototype.getEntity_ = function(type, req, done) {
done(new errors.ConfigError('No getter found for entity: ' + type));
} else {
var view_ = this.view_(req);
- var entity = view_.entities[type];
- if (entity) {
+ if (type in view_.entities) {
process.nextTick(function() {
- done(null, entity);
+ done(null, view_.entities[type]);
});
} else {
this.entityGetters_[type](req, function(err, entity) {
- if (!err && entity) {
+ if (!err) {
// cache entity for future access
view_.entities[type] = entity;
}
@@ -250,9 +249,16 @@ Manager.prototype.hasRole_ = function(role, req, done) {
}
done(err, has);
}
- var args = entity ?
- [entity, req, cacheBeforeDone] : [req, cacheBeforeDone];
- getter.apply(null, args);
+ if (role.entity) {
+ if (!entity) {
+ // don't even bother checking the relation
+ cacheBeforeDone(null, false);
+ } else {
+ getter.apply(null, [entity, req, cacheBeforeDone]);
+ }
+ } else {
+ getter.apply(null, [req, cacheBeforeDone]);
+ }
});
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.