Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 167 forks source link

How to remove all user roles in a group? #243

Closed MuyBien closed 7 years ago

MuyBien commented 7 years ago

Hi! I have several groups named for example: 'soccer', 'volleyball', 'waterpolo'... In each group, you can have one of 3 different roles: 'admin', 'captain', 'player'. I have a method to set a role to a user within a group, but I don't know the good method to remove all others roles before adding the new one. (I'm using the V2 package)

Removing one by one all roles (even if user do not have it)

Roles.removeUsersFromRoles( userID, 'admin', group );
Roles.removeUsersFromRoles( userID, 'captain', group );
Roles.removeUsersFromRoles( userID, 'player', group );
Roles.addUsersToRoles( userID, newRole, group );

Using setRole (working with groups?)

Roles.setUserRoles( userID,  newRole, group );

Thanks!

MuyBien commented 7 years ago

Roles.setUserRoles( userID, newRole, group );

seems to do the trick :)

mrvijaycode commented 7 years ago

The below is the best page to visit remove roles from SharePoint group. https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/SetPnPGroupPermissions.md

But here I want to know if I want to remove all Roles. How to do .

Please help me