Merge pull request #247 from haio/master
Ensure roleId and principalId to be string in Role#isInRole
This commit is contained in:
commit
6afa95311c
|
@ -373,8 +373,14 @@ Role.isInRole = function (role, context, callback) {
|
||||||
async.some(context.principals, function (p, done) {
|
async.some(context.principals, function (p, done) {
|
||||||
var principalType = p.type || undefined;
|
var principalType = p.type || undefined;
|
||||||
var principalId = p.id || 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) {
|
if (principalType && principalId) {
|
||||||
roleMappingModel.findOne({where: {roleId: result.id,
|
roleMappingModel.findOne({where: {roleId: roleId,
|
||||||
principalType: principalType, principalId: principalId}},
|
principalType: principalType, principalId: principalId}},
|
||||||
function (err, result) {
|
function (err, result) {
|
||||||
debug('Role mapping found: %j', result);
|
debug('Role mapping found: %j', result);
|
||||||
|
|
Loading…
Reference in New Issue