diff --git a/lib/index.js b/lib/index.js index bcba250..24bb212 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,6 +15,7 @@ function noQsMethod(options) { } var auth_timeout = setTimeout(function () { + socket.emit('error', new UnauthorizedError('request_expiration', 'Token wasn\'t received on time')); socket.disconnect('unauthorized'); }, options.timeout || 5000); @@ -22,6 +23,7 @@ function noQsMethod(options) { clearTimeout(auth_timeout); jwt.verify(data.token, options.secret, options, function(err, decoded) { if (err) { + socket.emit('error', new UnauthorizedError('invalid_token', err)); return socket.disconnect('unauthorized'); }