Skip to content

Commit

Permalink
Fix permission on ws events for screen sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Polidori committed Jun 5, 2019
1 parent 22a5fdb commit 04318d4
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1987,21 +1987,18 @@ function wsConnHdlr(socket) {
});
socket.on('message', function(data) {
try {
if (data.message === 'screenSharingStart' || data.message === 'screenSharingStop' || data.message === 'screenSharingAccepted') {
if (socket.nethcti && socket.nethcti.username && compAuthorization.authorizeScreenSharing(socket.nethcti.username) === true) {
logger.log.info(IDLOG, 'screen sharing (roomId "' + data.roomId + '"): authorization successful for user "' + socket.nethcti.username + '"');
} else if (socket.nethcti && socket.nethcti.username && compAuthorization.authorizeScreenSharing(socket.nethcti.username) === false) {
logger.log.warn(IDLOG, 'screen sharing (roomId "' + data.roomId + '") by user "' + socket.nethcti.username + '" has been failed: user does not have the authorization');
return;
} else {
logger.log.warn(IDLOG, 'screen sharing (roomId "' + data.roomId + '") has been failed: username not present into the socket');
return;
}
for (let socketId in wsid) {
if (data.destUser === wsid[socketId].username) {
if (wsServer.sockets.sockets[socketId]) {
wsServer.sockets.sockets[socketId].emit('message', data);
}
if (data.message === 'screenSharingStart' &&
socket.nethcti && socket.nethcti.username && compAuthorization.authorizeScreenSharing(socket.nethcti.username) === true) {

logger.log.info(IDLOG, 'screen sharing starting (roomId "' + data.roomId + '"): authorization successful for user "' + socket.nethcti.username + '"');
} else if (data.message === 'screenSharingStart') {
logger.log.warn(IDLOG, 'screen sharing start (roomId "' + data.roomId + '") by user "' + socket.nethcti.username + '" has been failed: user does not have the authorization');
return;
}
for (let socketId in wsid) {
if (data.destUser === wsid[socketId].username) {
if (wsServer.sockets.sockets[socketId]) {
wsServer.sockets.sockets[socketId].emit('message', data);
}
}
}
Expand Down

0 comments on commit 04318d4

Please sign in to comment.