Giter VIP home page Giter VIP logo

Comments (7)

mcrider avatar mcrider commented on July 30, 2024

Additional: This is the event handler that is calling addUsersToRoles (or removeUsersFromRoles, same problem):

Template.admin_users.events = {
  'click .admin': function() {
    if(!this._id) return false;
    if(_.contains(this.roles, "admin")) Roles.removeUsersFromRoles([this._id], ['admin']);
    else Roles.addUsersToRoles([this._id], ['admin']);
  },
};

And the value for 'this':

Object {
_id: "Bu75H9pQDafjx5EEc"
createdAt: 1365364990650
emails: Array[1]
roles: Array[0]
services: Object
__proto__: Object
}

from meteor-roles.

alanning avatar alanning commented on July 30, 2024

Hi Matt,

Thank you for reporting this!

I think this is due to the security update in Meteor v0.5.8. From the v0.5.8 release notes, "You must specify a single document ID when invoking [update & remove] from the client..."

Need to write tests for these failing cases and then add checks on the client to loop if more than one record needs to be updated/removed.

Good job tracking this down. Would you like to have a go at the fix? :-)

from meteor-roles.

mcrider avatar mcrider commented on July 30, 2024

Hi Adrian,

I've made a pull request with some code that should fix the issue, and also updated the documentation. Sorry, I'm really inexperienced with tests (especially in JS) so I don't think I can work on that just now (I also wasn't able to get the test suite to run anyway)...

Hope this helps!

from meteor-roles.

alanning avatar alanning commented on July 30, 2024

Hi Matt,

Great work! Thanks!

Re: tests
Yeah, I just tried running the existing tests and am having big problems with Meteorite and Meteor 0.6.0. I'll have to dig further into that.

One suggestion on the pull request. Instead of always performing the _.each, can you please add a check for Meteor.isClient and only do the loop on the client-side? Server-side would remain as before with the $in operator. That way the server doesn't take the performance hit of having to make multiple calls to the database. This is important in "user import" use-cases where an app could accept a large number of users and update their roles all in 1 db call.

from meteor-roles.

mcrider avatar mcrider commented on July 30, 2024

Sure, that makes sense. I've added some commits to my PR.

Yeah, the new 'var scoping' feature in Meteor 0.6.0 might be messing things up for you. Another heads up, if you haven't done it already, is to update Meteorite through npm (npm install -g meteorite i think) -- Otherwise meteorite will hang when trying to run commands through it.

from meteor-roles.

alanning avatar alanning commented on July 30, 2024

Closed!

I'll push to atmosphere and also see what I can do to get tests working again.

Thanks for the help!

from meteor-roles.

alanning avatar alanning commented on July 30, 2024

fyi, published v1.0.5 to atmosphere with your fix, got tests working (see readme), and added you to the contributors section

from meteor-roles.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.