Skip to content

Commit

Permalink
Bugfix: Issue rkusa#181
Browse files Browse the repository at this point in the history
Add dummy req.session.regenerate and req.session.save for passport 0.6.0
  • Loading branch information
zap-dev1 committed Nov 23, 2022
1 parent 8bf9697 commit b31c007
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/framework/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ const properties = {
}
}

// dummy implementation of methods that passport 0.6.0 expects the request to have
// see issue https://github.com/jaredhanson/passport/issues/904
const sessionProperties = {
regenerate: {
get: function () {
return (cb) => {cb()}
},
},
save: {
get: function () {
return (cb) => {cb()}
}
}
}

keys.forEach(function(key) {
properties[key] = {
get: function() {
Expand Down Expand Up @@ -137,6 +152,8 @@ const IncomingMessageExt = require('passport/lib/http/request')
exports.create = function(ctx, userProperty) {
const req = Object.create(ctx.request, properties)

Object.defineProperties(req.session, sessionProperties)

Object.defineProperty(req, userProperty, {
enumerable: true,
get: function() {
Expand Down

0 comments on commit b31c007

Please sign in to comment.