change the API
This commit is contained in:
10
lib/index.js
10
lib/index.js
@ -2,8 +2,10 @@ var xtend = require('xtend');
|
||||
var jwt = require('jsonwebtoken');
|
||||
var UnauthorizedError = require('./UnauthorizedError');
|
||||
|
||||
function noQsMethod(options, onConnection) {
|
||||
function noQsMethod(options) {
|
||||
return function (socket) {
|
||||
var server = this;
|
||||
|
||||
var auth_timeout = setTimeout(function () {
|
||||
socket.disconnect('unauthorized');
|
||||
}, options.timeout || 5000);
|
||||
@ -17,7 +19,7 @@ function noQsMethod(options, onConnection) {
|
||||
|
||||
socket.user = decoded;
|
||||
socket.emit('authenticated');
|
||||
onConnection(socket);
|
||||
server.$emit('authenticated', socket);
|
||||
});
|
||||
});
|
||||
|
||||
@ -36,8 +38,8 @@ function authorize(options, onConnection) {
|
||||
|
||||
var auth = xtend(defaults, options);
|
||||
|
||||
if (onConnection) {
|
||||
return noQsMethod(options, onConnection);
|
||||
if (!options.handshake) {
|
||||
return noQsMethod(options);
|
||||
}
|
||||
|
||||
return function(data, accept){
|
||||
|
Reference in New Issue
Block a user