nicolaslopezj / roles

The most advanced roles package for meteor
MIT License
87 stars 13 forks source link

Geeting Exception while invoking method '/countries/update' after upgrade into 2.1.2 #15

Closed chompomonim closed 7 years ago

chompomonim commented 8 years ago

I'm getting error on edit documents in any collection:

Exception while invoking method '/countries/update' TypeError: Object function () {                                                              // 1
I20160102-19:40:38.699(2)?   var i, key, output, ref, results, value;                                                         // 2
I20160102-19:40:38.699(2)?   output = {};                                                                                     // 2
I20160102-19:40:38.699(2)?   for (key = i = 0, ref = this.length; 0 <= ref ? i < ref : i > ref; key = 0 <= ref ? ++i : --i) {
I20160102-19:40:38.699(2)?     output[this[key]] = this[key];                                                                 // 3
I20160102-19:40:38.700(2)?   }                                                                                                // 3
I20160102-19:40:38.700(2)?   results = [];                                                                                    // 4
I20160102-19:40:38.700(2)?   for (key in output) {                                                                            //
I20160102-19:40:38.700(2)?     value = output[key];                                                                           //
I20160102-19:40:38.700(2)?     results.push(value);                                                                           // 4
I20160102-19:40:38.701(2)?   }                                                                                                // 4
I20160102-19:40:38.701(2)?   return results;                                                                                  //
I20160102-19:40:38.701(2)? } has no method 'indexOf'
I20160102-19:40:38.701(2)?     at helpers.js:7:20
I20160102-19:40:38.701(2)?     at Array.forEach (native)
I20160102-19:40:38.701(2)?     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
I20160102-19:40:38.701(2)?     at willChangeWithParent (helpers.js:6:5)
I20160102-19:40:38.702(2)?     at deny.update (roles.js:386:15)
I20160102-19:40:38.702(2)?     at packages/mongo/collection.js:1068:1
I20160102-19:40:38.702(2)?     at Array.some (native)
I20160102-19:40:38.702(2)?     at Function._.some._.any (packages/underscore/underscore.js:233:1)
I20160102-19:40:38.702(2)?     at [object Object].Mongo.Collection._validatedUpdate (packages/mongo/collection.js:1066:1)
I20160102-19:40:38.702(2)?     at [object Object].m.(anonymous function) (packages/mongo/collection.js:892:1)

After reverting into 1.5.3 everything works fine.

chompomonim commented 7 years ago

I don't know why, but in roles.js (look from line407) even when forbiddenFields equal [] for will still iterate and forbiddenFields[i] will be equal:

unique function () {
   var i, key, output, ref, results, value
   output = {};
   for (key = i = 0, ref = this.length; 0 <= ref ? i < ref : i > ref; key = 0 <= ref ? ++i : --i) {
I20161231-00:10:54.362(2)?     output[this[key]] = this[key];                                                                 
   }
   results = [];
   for (key in output) {
     value = output[key];
     results.push(value);
   }
   return results;
}

Will open poll request with fix.