Give client correct authentication status when joining a room. Fixes #166
parent
b19add7599
commit
fa032036d7
|
|
@ -2524,7 +2524,7 @@ export default class RoomClient
|
|||
canShareFiles : this._torrentSupport
|
||||
}));
|
||||
|
||||
const { roles, peers } = await this.sendRequest(
|
||||
const { authenticated, roles, peers } = await this.sendRequest(
|
||||
'join',
|
||||
{
|
||||
displayName : displayName,
|
||||
|
|
@ -2532,7 +2532,14 @@ export default class RoomClient
|
|||
rtpCapabilities : this._mediasoupDevice.rtpCapabilities
|
||||
});
|
||||
|
||||
logger.debug('_joinRoom() joined [peers:"%o", roles:"%o"]', peers, roles);
|
||||
logger.debug(
|
||||
'_joinRoom() joined [authenticated:"%s", peers:"%o", roles:"%o"]',
|
||||
authenticated,
|
||||
peers,
|
||||
roles
|
||||
);
|
||||
|
||||
store.dispatch(meActions.loggedIn(authenticated));
|
||||
|
||||
const myRoles = store.getState().me.roles;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class Peer extends EventEmitter
|
|||
|
||||
this._inLobby = false;
|
||||
|
||||
this._authenticated = false;
|
||||
|
||||
this._roles = [ userRoles.ALL ];
|
||||
|
||||
this._displayName = false;
|
||||
|
|
@ -146,6 +148,23 @@ class Peer extends EventEmitter
|
|||
this._inLobby = inLobby;
|
||||
}
|
||||
|
||||
get authenticated()
|
||||
{
|
||||
return this._authenticated;
|
||||
}
|
||||
|
||||
set authenticated(authenticated)
|
||||
{
|
||||
if (authenticated !== this._authenticated)
|
||||
{
|
||||
const oldAuthenticated = this._authenticated;
|
||||
|
||||
this._authenticated = authenticated;
|
||||
|
||||
this.emit('authenticationChanged', { oldAuthenticated });
|
||||
}
|
||||
}
|
||||
|
||||
get roles()
|
||||
{
|
||||
return this._roles;
|
||||
|
|
|
|||
|
|
@ -554,8 +554,9 @@ class Room extends EventEmitter
|
|||
.map((joinedPeer) => (joinedPeer.peerInfo));
|
||||
|
||||
cb(null, {
|
||||
roles : peer.roles,
|
||||
peers : peerInfos
|
||||
roles : peer.roles,
|
||||
peers : peerInfos,
|
||||
authenticated : peer.authenticated
|
||||
});
|
||||
|
||||
// Mark the new Peer as joined.
|
||||
|
|
|
|||
|
|
@ -354,10 +354,10 @@ async function setupAuth()
|
|||
if (!peer) // User has no socket session yet, make temporary
|
||||
peer = new Peer({ id: peerId, roomId });
|
||||
|
||||
if (peer && peer.roomId !== roomId) // The peer is mischievous
|
||||
if (peer.roomId !== roomId) // The peer is mischievous
|
||||
throw new Error('peer authenticated with wrong room');
|
||||
|
||||
if (peer && typeof config.userMapping === 'function')
|
||||
if (typeof config.userMapping === 'function')
|
||||
{
|
||||
await config.userMapping({
|
||||
peer,
|
||||
|
|
@ -366,6 +366,8 @@ async function setupAuth()
|
|||
});
|
||||
}
|
||||
|
||||
peer.authenticated = true;
|
||||
|
||||
res.send(loginHelper({
|
||||
displayName : peer.displayName,
|
||||
picture : peer.picture
|
||||
|
|
@ -530,10 +532,11 @@ async function runWebSocketServer()
|
|||
_userinfo
|
||||
} = socket.handshake.session.passport.user;
|
||||
|
||||
peer.authId= id;
|
||||
peer.authId = id;
|
||||
peer.displayName = displayName;
|
||||
peer.picture = picture;
|
||||
peer.email = email;
|
||||
peer.authenticated = true;
|
||||
|
||||
if (typeof config.userMapping === 'function')
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue