Comparing version 0.1.3 to 0.1.4
@@ -139,2 +139,29 @@ /** | ||
/** | ||
* Middleware that will authorize a third-party account using the given | ||
* `strategy` name, with optional `options`. | ||
* | ||
* If authorization is successful, the result provided by the strategy's verify | ||
* callback will be assigned to `req.account`. The existing login session and | ||
* `req.user` will be unaffected. | ||
* | ||
* This function is particularly useful when connecting third-party accounts | ||
* to the local account of a user that is currently authenticated. | ||
* | ||
* Examples: | ||
* | ||
* passport.authorize('twitter-authz', { failureRedirect: '/account' }); | ||
* | ||
* @param {String} strategy | ||
* @param {Object} options | ||
* @return {Function} middleware | ||
* @api public | ||
*/ | ||
Passport.prototype.authorize = function(strategy, options) { | ||
options = options || {}; | ||
options.assignProperty = 'account'; | ||
return authenticate(strategy, options, callback).bind(this); | ||
} | ||
/** | ||
* Registers a function used to serialize user objects into the session. | ||
@@ -247,3 +274,3 @@ * | ||
*/ | ||
exports.version = '0.1.3'; | ||
exports.version = '0.1.4'; | ||
@@ -250,0 +277,0 @@ /** |
@@ -22,2 +22,3 @@ /** | ||
* - `failureRedirect` After failed login, redirect to given URL | ||
* - `assignProperty` Assign the object provided by the verify callback to given property | ||
* | ||
@@ -32,6 +33,8 @@ * An optional `callback` can be supplied to allow the application to overrride | ||
* | ||
* passport.authenticate('local', function(err, user, profile) { | ||
* if (err) { return next(err) } | ||
* if (!user) { return res.redirect('/signin') } | ||
* res.redirect('/account'); | ||
* app.get('/protected', function(req, res, next) { | ||
* passport.authenticate('local', function(err, user, profile) { | ||
* if (err) { return next(err) } | ||
* if (!user) { return res.redirect('/signin') } | ||
* res.redirect('/account'); | ||
* })(req, res, next); | ||
* }); | ||
@@ -72,2 +75,5 @@ * | ||
return callback(null, user, profile); | ||
} else if (options.assignProperty) { | ||
req[options.assignProperty] = user; | ||
return next(); | ||
} | ||
@@ -74,0 +80,0 @@ |
{ | ||
"name": "passport", | ||
"version": "0.1.3", | ||
"description": "Authentication framework for Connect and Express.", | ||
"version": "0.1.4", | ||
"description": "Simple, unobtrusive authentication for Node.js.", | ||
"author": "Jared Hanson <jaredhanson@gmail.com> (http://www.jaredhanson.net/)", | ||
@@ -6,0 +6,0 @@ "repository": { |
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
21450
682