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-lib/server/methods/setAdminStatus.coffee

14 lines
481 B

Meteor.methods
setAdminStatus: (userId, admin) ->
if not Meteor.userId()
throw new Meteor.Error 'invalid-user', "[methods] setAdminStatus -> Invalid user"
unless RocketChat.authz.hasPermission( Meteor.userId(), 'assign-admin-role') is true
throw new Meteor.Error 'not-authorized', '[methods] setAdminStatus -> Not authorized'
if admin
RocketChat.authz.addUserRoles( userId, 'admin')
else
RocketChat.authz.removeUserFromRoles( userId, 'admin')
return true