yogiben / meteor-admin

A complete admin dashboard solution
https://atmospherejs.com/yogiben/admin
GNU General Public License v3.0
827 stars 261 forks source link

Applying roles changes in admin still doesn't work #329

Open reduxdj opened 8 years ago

reduxdj commented 8 years ago

using the package alanning:roles

Angarsk8 commented 8 years ago

Try this code. Put it somewhere in the server directory.

Meteor.startup(function () {
  Meteor.default_server.method_handlers.adminAddUserToRole = function(_id, role){
    check(_id, String);
    check(role, String);
    if (Roles.userIsInRole(this.userId, ['admin'])) {
      Roles.addUsersToRoles(_id, role);
    }
  };
  Meteor.default_server.method_handlers.adminRemoveUserToRole = function(_id, role){
    check(_id, String);
    check(role, String);
    if (Roles.userIsInRole(this.userId, ['admin'])) {
      Roles.removeUsersFromRoles(_id, role);
    }
  }
});