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
|
canShareFiles : this._torrentSupport
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { roles, peers } = await this.sendRequest(
|
const { authenticated, roles, peers } = await this.sendRequest(
|
||||||
'join',
|
'join',
|
||||||
{
|
{
|
||||||
displayName : displayName,
|
displayName : displayName,
|
||||||
|
|
@ -2532,7 +2532,14 @@ export default class RoomClient
|
||||||
rtpCapabilities : this._mediasoupDevice.rtpCapabilities
|
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;
|
const myRoles = store.getState().me.roles;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ class Peer extends EventEmitter
|
||||||
|
|
||||||
this._inLobby = false;
|
this._inLobby = false;
|
||||||
|
|
||||||
|
this._authenticated = false;
|
||||||
|
|
||||||
this._roles = [ userRoles.ALL ];
|
this._roles = [ userRoles.ALL ];
|
||||||
|
|
||||||
this._displayName = false;
|
this._displayName = false;
|
||||||
|
|
@ -146,6 +148,23 @@ class Peer extends EventEmitter
|
||||||
this._inLobby = inLobby;
|
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()
|
get roles()
|
||||||
{
|
{
|
||||||
return this._roles;
|
return this._roles;
|
||||||
|
|
|
||||||
|
|
@ -555,7 +555,8 @@ class Room extends EventEmitter
|
||||||
|
|
||||||
cb(null, {
|
cb(null, {
|
||||||
roles : peer.roles,
|
roles : peer.roles,
|
||||||
peers : peerInfos
|
peers : peerInfos,
|
||||||
|
authenticated : peer.authenticated
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mark the new Peer as joined.
|
// Mark the new Peer as joined.
|
||||||
|
|
|
||||||
|
|
@ -354,10 +354,10 @@ async function setupAuth()
|
||||||
if (!peer) // User has no socket session yet, make temporary
|
if (!peer) // User has no socket session yet, make temporary
|
||||||
peer = new Peer({ id: peerId, roomId });
|
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');
|
throw new Error('peer authenticated with wrong room');
|
||||||
|
|
||||||
if (peer && typeof config.userMapping === 'function')
|
if (typeof config.userMapping === 'function')
|
||||||
{
|
{
|
||||||
await config.userMapping({
|
await config.userMapping({
|
||||||
peer,
|
peer,
|
||||||
|
|
@ -366,6 +366,8 @@ async function setupAuth()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peer.authenticated = true;
|
||||||
|
|
||||||
res.send(loginHelper({
|
res.send(loginHelper({
|
||||||
displayName : peer.displayName,
|
displayName : peer.displayName,
|
||||||
picture : peer.picture
|
picture : peer.picture
|
||||||
|
|
@ -534,6 +536,7 @@ async function runWebSocketServer()
|
||||||
peer.displayName = displayName;
|
peer.displayName = displayName;
|
||||||
peer.picture = picture;
|
peer.picture = picture;
|
||||||
peer.email = email;
|
peer.email = email;
|
||||||
|
peer.authenticated = true;
|
||||||
|
|
||||||
if (typeof config.userMapping === 'function')
|
if (typeof config.userMapping === 'function')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue