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); 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) { auth.passport.deserializeUser(userKey, function(err, user) {
data[ auth.userProperty ] = 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'), var express = require('express'),
connect = require('connect'), connect = require('connect'),
passport = require('passport'), passport = require('passport'),
http = require('http'); http = require('http'),
xtend = require('xtend');
var socketIo = require('socket.io'), var socketIo = require('socket.io'),
passportSocketIo = require('../../lib'); passportSocketIo = require('../../lib');
@ -14,7 +15,13 @@ var server;
require('./setupPassport'); require('./setupPassport');
exports.start = function (callback) { exports.start = function (options, callback) {
if(typeof options == 'function'){
callback = options;
options = {};
}
var app = express(); var app = express();
app.configure(function(){ app.configure(function(){
app.use(express.cookieParser(cookieSecret)); app.use(express.cookieParser(cookieSecret));
@ -48,11 +55,11 @@ exports.start = function (callback) {
var sio = socketIo.listen(server); var sio = socketIo.listen(server);
sio.configure(function(){ sio.configure(function(){
this.set('authorization', passportSocketIo.authorize({ this.set('authorization', passportSocketIo.authorize(xtend({
sessionKey: sessionKey, sessionKey: sessionKey,
sessionStore: sessionStore, sessionStore: sessionStore,
sessionSecret: cookieSecret sessionSecret: cookieSecret
})); }, options)));
this.set('log level', 0); this.set('log level', 0);