Ensure roleId and principalId to be string in Role#isInRole

This commit is contained in:
haio 2014-05-03 11:43:03 +08:00
parent 1077a7f288
commit 429052a0db
1 changed files with 7 additions and 1 deletions

View File

@ -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);