meteor-admin icon indicating copy to clipboard operation
meteor-admin copied to clipboard

Applying roles changes in admin still doesn't work

Open reduxdj opened this issue 9 years ago • 1 comments
trafficstars

using the package alanning:roles

reduxdj avatar Jan 28 '16 20:01 reduxdj

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

Angarsk8 avatar Feb 28 '16 07:02 Angarsk8