diff --git a/server/config/config.example.js b/server/config/config.example.js index 5f2a42f..a358a14 100644 --- a/server/config/config.example.js +++ b/server/config/config.example.js @@ -33,6 +33,12 @@ module.exports = // Any http request is redirected to https. // Listening port for http server. listeningRedirectPort : 80, + // If this is set to true, only signed-in users will be able + // to join a room directly. Non-signed-in users (guests) will + // always be put in the lobby regardless of room lock status. + // If false, there is no difference between guests and signed-in + // users when joining. + requireSignInToAccess : true, // Mediasoup settings mediasoup : { diff --git a/server/lib/Room.js b/server/lib/Room.js index a59a340..6f7a379 100644 --- a/server/lib/Room.js +++ b/server/lib/Room.js @@ -244,18 +244,28 @@ class Room extends EventEmitter delete this._peers[peerId]; } else if (this._locked) // Don't allow connections to a locked room + this._parkPeer({ peerId, consume, socket }) + else if (config.requireSignInToAccess) // Only allow signed in users directly into room { - this._lobby.parkPeer({ peerId, consume, socket }); + const { passport } = socket.handshake.session; - Object.values(this._peers).forEach((peer) => - { - this._notification(peer.socket, 'parkedPeer', { peerId }); - }); - - return; + if (passport && passport.user) + this._peerJoining({ peerId, consume, socket }); + else + this._parkPeer({ peerId, consume, socket }) } + else + this._peerJoining({ peerId, consume, socket }); + } - this._peerJoining({ peerId, consume, socket }); + _parkPeer({ peerId, consume, socket }) + { + this._lobby.parkPeer({ peerId, consume, socket }); + + Object.values(this._peers).forEach((peer) => + { + this._notification(peer.socket, 'parkedPeer', { peerId }); + }); } _peerJoining({ peerId, consume, socket })