From 2d08e656b82f83b1851a74f1c214670f069371b0 Mon Sep 17 00:00:00 2001 From: Benjamin Boudreau Date: Wed, 11 Mar 2015 10:25:11 -0400 Subject: [PATCH] Handling owner being a relation/function --- common/models/role.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/models/role.js b/common/models/role.js index 46e2101a..2c005cde 100644 --- a/common/models/role.js +++ b/common/models/role.js @@ -161,7 +161,8 @@ module.exports = function(Role) { } debug('Model found: %j', inst); var ownerId = inst.userId || inst.owner; - if (ownerId) { + // Ensure ownerId exists and is not a function/relation + if (ownerId && 'function' !== typeof ownerId) { if (callback) callback(null, matches(ownerId, userId)); return; } else {