2
1
mirror of https://github.com/Thream/socketio-jwt.git synced 2024-07-21 09:38:31 +02:00

fix bug calling both success and accept

This commit is contained in:
Jose F. Romaniello 2013-01-07 11:30:15 -03:00
parent 79878b036c
commit a1e46b1fbd
2 changed files with 15 additions and 11 deletions

View File

@ -46,15 +46,12 @@ function authorize(options) {
return accept(null, false);
}
if( auth.success ) {
auth.passport.deserializeUser(userKey, function(err, user) {
data[ auth.userProperty ] = user;
return auth.success( data, accept );
});
}
auth.passport.deserializeUser(userKey, function(err, user) {
data[ auth.userProperty ] = user;
return accept(null, true);
if( auth.success ) {
return auth.success( data, accept );
}
accept(null, true);
});
});

View File

@ -1,7 +1,8 @@
var express = require('express'),
connect = require('connect'),
passport = require('passport'),
http = require('http');
http = require('http'),
xtend = require('xtend');
var socketIo = require('socket.io'),
passportSocketIo = require('../../lib');
@ -14,7 +15,13 @@ var server;
require('./setupPassport');
exports.start = function (callback) {
exports.start = function (options, callback) {
if(typeof options == 'function'){
callback = options;
options = {};
}
var app = express();
app.configure(function(){
app.use(express.cookieParser(cookieSecret));
@ -48,11 +55,11 @@ exports.start = function (callback) {
var sio = socketIo.listen(server);
sio.configure(function(){
this.set('authorization', passportSocketIo.authorize({
this.set('authorization', passportSocketIo.authorize(xtend({
sessionKey: sessionKey,
sessionStore: sessionStore,
sessionSecret: cookieSecret
}));
}, options)));
this.set('log level', 0);