Skip to content

Commit

Permalink
Exted req in authenticate, rather than initialize.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Dec 15, 2021
1 parent 0f0aa0e commit 77ee3a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 7 additions & 0 deletions lib/middleware/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ module.exports = function authenticate(passport, name, options, callback) {
}

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;

// expose session manager
req.sessionManager = passport._sm;

Expand Down
7 changes: 0 additions & 7 deletions lib/middleware/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ module.exports = function initialize(passport, options) {
options = options || {};

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;
}
Expand Down

0 comments on commit 77ee3a6

Please sign in to comment.