Comparing version
@@ -7,2 +7,15 @@ # Changelog | ||
## [Unreleased] | ||
## [0.5.1] - 2021-12-15 | ||
### Added | ||
- Informative error message in session strategy if session support is not | ||
available. | ||
### Changed | ||
- `authenticate()` middleware, rather than `initialize()` middleware, extends | ||
request with `login()`, `logIn()`, `logout()`, `logOut()`, `isAuthenticated()`, | ||
and `isUnauthenticated()` functions. | ||
## [0.5.0] - 2021-09-23 | ||
@@ -27,1 +40,4 @@ ### Changed | ||
values. | ||
[Unreleased]: https://github.com/jaredhanson/passport/compare/v0.5.1...HEAD | ||
[0.5.1]: https://github.com/jaredhanson/passport/compare/v0.5.0...v0.5.1 |
@@ -35,8 +35,7 @@ var req = exports = module.exports = {}; | ||
this[property] = user; | ||
if (session) { | ||
if (!this._passport) { throw new Error('passport.initialize() middleware not in use'); } | ||
if (session && this._sessionManager) { | ||
if (typeof done != 'function') { throw new Error('req#login requires a callback function'); } | ||
var self = this; | ||
this._passport.instance._sm.logIn(this, user, function(err) { | ||
this._sessionManager.logIn(this, user, function(err) { | ||
if (err) { self[property] = null; return done(err); } | ||
@@ -60,4 +59,4 @@ done(); | ||
this[property] = null; | ||
if (this._passport) { | ||
this._passport.instance._sm.logOut(this); | ||
if (this._sessionManager) { | ||
this._sessionManager.logOut(this); | ||
} | ||
@@ -64,0 +63,0 @@ }; |
@@ -95,2 +95,11 @@ /** | ||
return function authenticate(req, res, next) { | ||
req.login = | ||
req.logIn = req.logIn || IncomingMessageExt.logIn; | ||
req.logout = | ||
req.logOut = req.logOut || IncomingMessageExt.logOut; | ||
req.isAuthenticated = req.isAuthenticated || IncomingMessageExt.isAuthenticated; | ||
req.isUnauthenticated = req.isUnauthenticated || IncomingMessageExt.isUnauthenticated; | ||
req._sessionManager = passport._sm; | ||
// accumulator for failures from each strategy in the chain | ||
@@ -97,0 +106,0 @@ var failures = []; |
@@ -52,15 +52,5 @@ /** | ||
return function initialize(req, res, next) { | ||
req.login = | ||
req.logIn = IncomingMessageExt.logIn; | ||
req.logout = | ||
req.logOut = IncomingMessageExt.logOut; | ||
req.isAuthenticated = IncomingMessageExt.isAuthenticated; | ||
req.isUnauthenticated = IncomingMessageExt.isUnauthenticated; | ||
if (options.userProperty) { | ||
req._userProperty = options.userProperty; | ||
} | ||
req._passport = {}; | ||
req._passport.instance = passport; | ||
@@ -67,0 +57,0 @@ next(); |
@@ -46,3 +46,3 @@ /** | ||
SessionStrategy.prototype.authenticate = function(req, options) { | ||
if (!req._passport) { return this.error(new Error('passport.initialize() middleware not in use')); } | ||
if (!req.session) { return this.error(new Error('Login sessions require session support. Did you forget to use `express-session` middleware?')); } | ||
options = options || {}; | ||
@@ -49,0 +49,0 @@ |
{ | ||
"name": "passport", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Simple, unobtrusive authentication for Node.js.", | ||
@@ -15,5 +15,5 @@ "keywords": [ | ||
"email": "jaredhanson@gmail.com", | ||
"url": "http://www.jaredhanson.net/" | ||
"url": "https://www.jaredhanson.me/" | ||
}, | ||
"homepage": "http://passportjs.org/", | ||
"homepage": "https://www.passportjs.org/", | ||
"repository": { | ||
@@ -24,3 +24,3 @@ "type": "git", | ||
"bugs": { | ||
"url": "http://github.com/jaredhanson/passport/issues" | ||
"url": "https://github.com/jaredhanson/passport/issues" | ||
}, | ||
@@ -35,3 +35,3 @@ "funding": { | ||
"type": "MIT", | ||
"url": "http://opensource.org/licenses/MIT" | ||
"url": "https://opensource.org/licenses/MIT" | ||
} | ||
@@ -38,0 +38,0 @@ ], |
@@ -174,2 +174,2 @@ [](http://passportjs.org) | ||
Copyright (c) 2011-2019 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)> | ||
Copyright (c) 2011-2021 Jared Hanson <[https://www.jaredhanson.me/](https://www.jaredhanson.me/)> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
65642
0.32%1056
-0.19%