Comparing version 0.1.5 to 0.1.6
@@ -37,9 +37,10 @@ /** | ||
options = options || {}; | ||
var property = this._passport.instance._userProperty || 'user'; | ||
var session = (options.session === undefined) ? true : options.session; | ||
this.user = user; | ||
this[property] = user; | ||
if (session) { | ||
var self = this; | ||
this._passport.instance.serializeUser(user, function(err, obj) { | ||
if (err) { self.user = null; return done(err); } | ||
if (err) { self[property] = null; return done(err); } | ||
self._passport.session.user = obj; | ||
@@ -61,3 +62,6 @@ done(); | ||
if (!this._passport) throw new Error('passport.initialize() middleware not in use'); | ||
this.user = null; | ||
var property = this._passport.instance._userProperty || 'user'; | ||
this[property] = null; | ||
delete this._passport.session.user; | ||
@@ -73,3 +77,8 @@ }; | ||
req.isAuthenticated = function() { | ||
return (this.user) ? true : false; | ||
var property = 'user'; | ||
if (this._passport && this._passport.instance._userProperty) { | ||
property = this._passport.instance._userProperty; | ||
} | ||
return (this[property]) ? true : false; | ||
}; | ||
@@ -76,0 +85,0 @@ |
@@ -24,2 +24,4 @@ /** | ||
this._userProperty = 'user'; | ||
this.use(new SessionStrategy()); | ||
@@ -60,2 +62,5 @@ }; | ||
* | ||
* Options: | ||
* - `userProperty` Property to set on `req` upon login, defaults to _user_ | ||
* | ||
* Examples: | ||
@@ -67,6 +72,14 @@ * | ||
* | ||
* app.configure(function() { | ||
* app.use(passport.initialize({ userProperty: 'currentUser' })); | ||
* }); | ||
* | ||
* @param {Object} options | ||
* @return {Function} middleware | ||
* @api public | ||
*/ | ||
Passport.prototype.initialize = function() { | ||
Passport.prototype.initialize = function(options) { | ||
options = options || {}; | ||
this._userProperty = options.userProperty || 'user'; | ||
return initialize().bind(this); | ||
@@ -161,7 +174,7 @@ } | ||
*/ | ||
Passport.prototype.authorize = function(strategy, options) { | ||
Passport.prototype.authorize = function(strategy, options, callback) { | ||
options = options || {}; | ||
options.assignProperty = 'account'; | ||
return authenticate(strategy, options).bind(this); | ||
return authenticate(strategy, options, callback).bind(this); | ||
} | ||
@@ -277,3 +290,3 @@ | ||
*/ | ||
exports.version = '0.1.5'; | ||
require('pkginfo')(module, 'version'); | ||
@@ -280,0 +293,0 @@ /** |
@@ -54,3 +54,3 @@ /** | ||
req._passport.instance = passport; | ||
//console.log('!! session: ' + util.inspect(req.session)); | ||
@@ -57,0 +57,0 @@ |
@@ -42,3 +42,4 @@ /** | ||
if (err) { return self.error(err); } | ||
req.user = user; | ||
var property = req._passport.instance._userProperty || 'user'; | ||
req[property] = user; | ||
self.pass(); | ||
@@ -45,0 +46,0 @@ }); |
{ | ||
"name": "passport", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Simple, unobtrusive authentication for Node.js.", | ||
"author": "Jared Hanson <jaredhanson@gmail.com> (http://www.jaredhanson.net/)", | ||
"author": { "name": "Jared Hanson", "email": "jaredhanson@gmail.com", "url": "http://www.jaredhanson.net/" }, | ||
"homepage": "http://passportjs.org/", | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/jaredhanson/passport.git" | ||
"url": "git://github.com/jaredhanson/passport.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/jaredhanson/passport/issues" | ||
}, | ||
"main": "./lib/passport", | ||
"dependencies": { | ||
"pkginfo": "0.2.x" | ||
}, | ||
"devDependencies": { | ||
"vows": "0.6.x" | ||
}, | ||
"engines": { "node": ">= 0.4.0" }, | ||
"licenses": [ { | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} ], | ||
"keywords": ["express", "connect", "auth", "authn", "authentication"] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
22531
700
0
1
1
1
+ Addedpkginfo@0.2.x
+ Addedpkginfo@0.2.3(transitive)