Force principalId to be a string.

Added a defensive check for undefined to avoid problems
when converting to a string.
This commit is contained in:
Chris S 2014-10-22 10:05:29 -05:00
parent c65b80432b
commit cff0e15936
1 changed files with 4 additions and 0 deletions

View File

@ -355,6 +355,10 @@ module.exports = function(Role) {
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) {
addRole(principalId);