Is there a way we can integrate JWT into the SocketIO controller. One recommendation is to add a middleware like so:
io.use(function(socket, next){
if (socket.handshake.query && socket.handshake.query.token){
jwt.verify(socket.handshake.query.token, 'SECRET_KEY', function(err, decoded) {
if (err) return next(new Error('Authentication error'));
socket.decoded = decoded;
next();
});
}
else {
next(new Error('Authentication error'));
}
})
How can we access the io object to connect such a middleware?
Is there a way we can integrate JWT into the SocketIO controller. One recommendation is to add a middleware like so:
How can we access the
ioobject to connect such a middleware?