diff --git a/lib/models/role.js b/lib/models/role.js index 86ff5cc3..8b64796f 100644 --- a/lib/models/role.js +++ b/lib/models/role.js @@ -373,8 +373,14 @@ Role.isInRole = function (role, context, callback) { async.some(context.principals, function (p, done) { var principalType = p.type || undefined; var principalId = p.id || undefined; + var roleId = result.id.toString(); + + if(principalId !== null && principalId !== undefined && (typeof principalId !== 'string') ) { + principalId = principalId.toString(); + } + if (principalType && principalId) { - roleMappingModel.findOne({where: {roleId: result.id, + roleMappingModel.findOne({where: {roleId: roleId, principalType: principalType, principalId: principalId}}, function (err, result) { debug('Role mapping found: %j', result);