From cff0e15936fb1f3550b806b81f9e54f77f358175 Mon Sep 17 00:00:00 2001 From: Chris S Date: Wed, 22 Oct 2014 10:05:29 -0500 Subject: [PATCH 1/2] Force principalId to be a string. Added a defensive check for undefined to avoid problems when converting to a string. --- common/models/role.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/models/role.js b/common/models/role.js index a86dfcff7..e5703b328 100644 --- a/common/models/role.js +++ b/common/models/role.js @@ -354,6 +354,10 @@ module.exports = function(Role) { // Check against the role mappings var principalType = p.type || undefined; var principalId = p.id || undefined; + + if(typeof principalId !== 'string' && typeof principalId !== 'undefined') { + principalId = principalId.toString(); + } // Add the role itself if (principalType === RoleMapping.ROLE && principalId) { From f67810785964a94b9e633f61159bc3daf9d39c75 Mon Sep 17 00:00:00 2001 From: Chris S Date: Wed, 22 Oct 2014 11:35:25 -0500 Subject: [PATCH 2/2] Adjust id handling to deal with 0 and null --- common/models/role.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/models/role.js b/common/models/role.js index e5703b328..406389d95 100644 --- a/common/models/role.js +++ b/common/models/role.js @@ -353,9 +353,9 @@ module.exports = function(Role) { context.principals.forEach(function(p) { // Check against the role mappings var principalType = p.type || undefined; - var principalId = p.id || undefined; + var principalId = p.id == null ? undefined : p.id; - if(typeof principalId !== 'string' && typeof principalId !== 'undefined') { + if(typeof principalId !== 'string' && principalId != null) { principalId = principalId.toString(); }