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

24 lines
684 B

Meteor.methods
canAccessRoom: (rid, userId) ->
check rid, String
check userId, String
user = RocketChat.models.Users.findOneById userId, fields: username: 1
unless user?.username
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'canAccessRoom' }
unless rid
throw new Meteor.Error 'error-invalid-room', 'Invalid room', { method: 'canAccessRoom' }
room = RocketChat.models.Rooms.findOneById rid
if room
if RocketChat.authz.canAccessRoom.call(this, room, user)
room.username = user.username
return room
else
return false
else
throw new Meteor.Error 'error-invalid-room', 'Invalid room', { method: 'canAccessRoom' }