The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-authorization/server/functions/removeUserFromRoles.js

27 lines
755 B

RocketChat.authz.removeUserFromRoles = function(userId, roleNames, scope) {
if (!userId || !roleNames) {
return false;
}
const user = RocketChat.models.Users.findOneById(userId);
if (!user) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
function: 'RocketChat.authz.removeUserFromRoles'
});
}
roleNames = [].concat(roleNames);
const existingRoleNames = _.pluck(RocketChat.authz.getRoles(), '_id');
const invalidRoleNames = _.difference(roleNames, existingRoleNames);
if (!_.isEmpty(invalidRoleNames)) {
throw new Meteor.Error('error-invalid-role', 'Invalid role', {
function: 'RocketChat.authz.removeUserFromRoles'
});
}
RocketChat.models.Roles.removeUserRoles(userId, roleNames, scope);
return true;
};