Need to check for undefined.
This commit is contained in:
+10
-7
@@ -36,6 +36,8 @@ class Peer extends EventEmitter
|
||||
|
||||
this._consumers = new Map();
|
||||
|
||||
this._checkAuthentication();
|
||||
|
||||
this._handlePeer();
|
||||
}
|
||||
|
||||
@@ -60,15 +62,9 @@ class Peer extends EventEmitter
|
||||
|
||||
_handlePeer()
|
||||
{
|
||||
this.authenticated =
|
||||
this.socket.handshake.session.passport &&
|
||||
this.socket.handshake.session.passport.user;
|
||||
|
||||
this.socket.use((packet, next) =>
|
||||
{
|
||||
this.authenticated =
|
||||
this.socket.handshake.session.passport &&
|
||||
this.socket.handshake.session.passport.user;
|
||||
this._checkAuthentication();
|
||||
|
||||
return next();
|
||||
});
|
||||
@@ -84,6 +80,13 @@ class Peer extends EventEmitter
|
||||
});
|
||||
}
|
||||
|
||||
_checkAuthentication()
|
||||
{
|
||||
this.authenticated =
|
||||
Boolean(this.socket.handshake.session.passport) &&
|
||||
Boolean(this.socket.handshake.session.passport.user);
|
||||
}
|
||||
|
||||
get id()
|
||||
{
|
||||
return this._id;
|
||||
|
||||
Reference in New Issue
Block a user