Some cleanup.
parent
cacc9abf7c
commit
bb8cf02c23
|
|
@ -321,12 +321,7 @@ export default class RoomClient
|
|||
|
||||
const { displayName, picture } = data;
|
||||
|
||||
if (store.getState().room.joined || store.getState().room.inLobby)
|
||||
{
|
||||
this.changeDisplayName(displayName);
|
||||
this.changeProfilePicture(picture);
|
||||
}
|
||||
|
||||
store.dispatch(stateActions.setDisplayName(displayName));
|
||||
store.dispatch(stateActions.setPicture(picture));
|
||||
store.dispatch(stateActions.loggedIn());
|
||||
|
||||
|
|
|
|||
|
|
@ -12,18 +12,24 @@ class Peer extends EventEmitter
|
|||
|
||||
this._id = id;
|
||||
|
||||
this._authId = null;
|
||||
|
||||
this._socket = socket;
|
||||
|
||||
this._closed = false;
|
||||
|
||||
this._joined = false;
|
||||
|
||||
this._inLobby = false;
|
||||
|
||||
this._authenticated = false;
|
||||
|
||||
this._displayName = false;
|
||||
|
||||
this._picture = null;
|
||||
|
||||
this._email = null;
|
||||
|
||||
this._device = null;
|
||||
|
||||
this._rtpCapabilities = null;
|
||||
|
|
@ -71,20 +77,10 @@ class Peer extends EventEmitter
|
|||
|
||||
this.socket.on('request', (request, cb) =>
|
||||
{
|
||||
logger.debug(
|
||||
'Peer "request" event [method:"%s", peer:"%s"]',
|
||||
request.method, this.id);
|
||||
|
||||
if (this._closed)
|
||||
return;
|
||||
|
||||
this._handleSocketRequest(request, cb)
|
||||
.catch((error) =>
|
||||
{
|
||||
logger.error('request failed [error:"%o"]', error);
|
||||
|
||||
cb(error);
|
||||
});
|
||||
this._handleSocketRequest(request, cb).catch(cb);
|
||||
});
|
||||
|
||||
this.socket.on('disconnect', () =>
|
||||
|
|
@ -100,12 +96,6 @@ class Peer extends EventEmitter
|
|||
|
||||
async _handleSocketRequest(request, cb)
|
||||
{
|
||||
logger.debug(
|
||||
'_handleSocketRequest [peer:"%s"], [request:"%s"]',
|
||||
this.id,
|
||||
request.method
|
||||
);
|
||||
|
||||
if (this._closed)
|
||||
return;
|
||||
|
||||
|
|
@ -121,14 +111,45 @@ class Peer extends EventEmitter
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'changeProfilePicture':
|
||||
{
|
||||
const { picture } = request.data;
|
||||
|
||||
this.picture = picture;
|
||||
|
||||
cb();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_checkAuthentication()
|
||||
{
|
||||
this.authenticated =
|
||||
if (
|
||||
Boolean(this.socket.handshake.session.passport) &&
|
||||
Boolean(this.socket.handshake.session.passport.user);
|
||||
Boolean(this.socket.handshake.session.passport.user)
|
||||
)
|
||||
{
|
||||
const {
|
||||
id,
|
||||
displayName,
|
||||
picture,
|
||||
email
|
||||
} = this.socket.handshake.session.passport.user;
|
||||
|
||||
id && (this.authId = id);
|
||||
displayName && (this.displayName = displayName);
|
||||
picture && (this.picture = picture);
|
||||
email && (this.email = email);
|
||||
|
||||
this.authenticated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.authenticated = false;
|
||||
}
|
||||
}
|
||||
|
||||
get id()
|
||||
|
|
@ -141,6 +162,16 @@ class Peer extends EventEmitter
|
|||
this._id = id;
|
||||
}
|
||||
|
||||
get authId()
|
||||
{
|
||||
return this._authId;
|
||||
}
|
||||
|
||||
set authId(authId)
|
||||
{
|
||||
this._authId = authId;
|
||||
}
|
||||
|
||||
get socket()
|
||||
{
|
||||
return this._socket;
|
||||
|
|
@ -166,6 +197,16 @@ class Peer extends EventEmitter
|
|||
this._joined = joined;
|
||||
}
|
||||
|
||||
get inLobby()
|
||||
{
|
||||
return this._inLobby;
|
||||
}
|
||||
|
||||
set inLobby(inLobby)
|
||||
{
|
||||
this._inLobby = inLobby;
|
||||
}
|
||||
|
||||
get authenticated()
|
||||
{
|
||||
return this._authenticated;
|
||||
|
|
@ -217,6 +258,16 @@ class Peer extends EventEmitter
|
|||
}
|
||||
}
|
||||
|
||||
get email()
|
||||
{
|
||||
return this._email;
|
||||
}
|
||||
|
||||
set email(email)
|
||||
{
|
||||
this._email = email;
|
||||
}
|
||||
|
||||
get device()
|
||||
{
|
||||
return this._device;
|
||||
|
|
|
|||
|
|
@ -263,10 +263,7 @@ class Room extends EventEmitter
|
|||
// checks both room and lobby
|
||||
checkEmpty()
|
||||
{
|
||||
if ((this._peers.size == 0) && (this._lobby.checkEmpty()))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (this._peers.size == 0) && (this._lobby.checkEmpty());
|
||||
}
|
||||
|
||||
_parkPeer(parkPeer)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"body-parser": "^1.19.0",
|
||||
"colors": "^1.4.0",
|
||||
"compression": "^1.7.4",
|
||||
"connect-redis": "^4.0.3",
|
||||
"cookie-parser": "^1.4.4",
|
||||
"debug": "^4.1.1",
|
||||
"express": "^4.17.1",
|
||||
|
|
@ -21,6 +22,7 @@
|
|||
"mediasoup": "^3.0.12",
|
||||
"openid-client": "^3.7.3",
|
||||
"passport": "^0.4.0",
|
||||
"redis": "^2.8.0",
|
||||
"socket.io": "^2.3.0",
|
||||
"spdy": "^4.0.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@ const helmet = require('helmet');
|
|||
const httpHelper = require('./httpHelper');
|
||||
// auth
|
||||
const passport = require('passport');
|
||||
const redis = require('redis');
|
||||
const client = redis.createClient();
|
||||
const { Issuer, Strategy } = require('openid-client');
|
||||
const expressSession = require('express-session');
|
||||
const RedisStore = require('connect-redis')(expressSession);
|
||||
const sharedSession = require('express-socket.io-session');
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
|
@ -67,6 +70,7 @@ const session = expressSession({
|
|||
secret : config.cookieSecret,
|
||||
resave : true,
|
||||
saveUninitialized : true,
|
||||
store : new RedisStore({ client }),
|
||||
cookie : {
|
||||
secure : true,
|
||||
httpOnly : true
|
||||
|
|
@ -171,10 +175,9 @@ async function setupAuth(oidcIssuer)
|
|||
// resolved from the issuer configuration, instead of true you may provide
|
||||
// any of the supported values directly, i.e. "S256" (recommended) or "plain"
|
||||
const usePKCE = false;
|
||||
const client = oidcClient;
|
||||
|
||||
oidcStrategy = new Strategy(
|
||||
{ client, params, passReqToCallback, usePKCE },
|
||||
{ oidcClient, params, passReqToCallback, usePKCE },
|
||||
(tokenset, userinfo, done) =>
|
||||
{
|
||||
const user =
|
||||
|
|
|
|||
Loading…
Reference in New Issue