Need to check for undefined.
parent
39c3f7c36d
commit
6dc3f537e4
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue