Skip to content

Commit 959aef5

Browse files
authored
Merge pull request #898 from jaredhanson/fix-reinitialize
Extend request in initialize middleware
2 parents e1e4e1f + 498d09f commit 959aef5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
10+
- `initialize()` middleware extends request with `login()`, `logIn()`,
11+
`logout()`, `logOut()`, `isAuthenticated()`, and `isUnauthenticated()` functions
12+
again, reverting change from 0.5.1.
813

914
## [0.5.2] - 2021-12-16
1015
### Fixed

lib/middleware/initialize.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ module.exports = function initialize(passport, options) {
4949
options = options || {};
5050

5151
return function initialize(req, res, next) {
52+
req.login =
53+
req.logIn = req.logIn || IncomingMessageExt.logIn;
54+
req.logout =
55+
req.logOut = req.logOut || IncomingMessageExt.logOut;
56+
req.isAuthenticated = req.isAuthenticated || IncomingMessageExt.isAuthenticated;
57+
req.isUnauthenticated = req.isUnauthenticated || IncomingMessageExt.isUnauthenticated;
58+
59+
req._sessionManager = passport._sm;
60+
5261
if (options.userProperty) {
5362
req._userProperty = options.userProperty;
5463
}

0 commit comments

Comments
 (0)