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._consumers = new Map();
|
||||||
|
|
||||||
|
this._checkAuthentication();
|
||||||
|
|
||||||
this._handlePeer();
|
this._handlePeer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,15 +62,9 @@ class Peer extends EventEmitter
|
|||||||
|
|
||||||
_handlePeer()
|
_handlePeer()
|
||||||
{
|
{
|
||||||
this.authenticated =
|
|
||||||
this.socket.handshake.session.passport &&
|
|
||||||
this.socket.handshake.session.passport.user;
|
|
||||||
|
|
||||||
this.socket.use((packet, next) =>
|
this.socket.use((packet, next) =>
|
||||||
{
|
{
|
||||||
this.authenticated =
|
this._checkAuthentication();
|
||||||
this.socket.handshake.session.passport &&
|
|
||||||
this.socket.handshake.session.passport.user;
|
|
||||||
|
|
||||||
return next();
|
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()
|
get id()
|
||||||
{
|
{
|
||||||
return this._id;
|
return this._id;
|
||||||
|
|||||||
Reference in New Issue
Block a user