From efef45309fc6f2e872f6fffc14f930afc88b741f Mon Sep 17 00:00:00 2001 From: Richard Assar Date: Sun, 30 Jun 2013 20:06:21 +0100 Subject: [PATCH] Allow 0 value for serialized user (id) --- lib/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 21954ec..bd9122d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -26,7 +26,7 @@ function authorize(options) { }; var auth = xtend({}, defaults, options ); - + auth.userProperty = auth.passport._userProperty || 'user'; if (typeof auth.cookieParser === 'undefined' || !auth.cookieParser) { @@ -55,10 +55,11 @@ function authorize(options) { var userKey = session[ auth.passport._key ][ auth.userProperty ]; - if( !userKey && auth.fail ) { - return auth.fail( data, accept ); - } else if( !userKey ) { - return accept(null, false); + if(userKey === undefined) + if(auth.fail) + return auth.fail( data, accept ); + else + return accept(null, false); } auth.passport.deserializeUser(userKey, function(err, user) {