Join our mailing list Subscribe Us

npm package passport.js upgrade (0.4.1 to 0.6.0) issue



--> In this upgrade i faced issue with the versions which i was using for passport. I should have modified all the places with new passport version.

--> secondly it started showing the Logout issue, as per documentation from passport they said signature for logout function got changed and new implementation is based on async hence new logout will expect the callback function.

below is the new signature, 

req.logout(
    function(err) { 
        if (err) { 
            return next(err); 
        }
     res.redirect('/'); 
});

old signature was,
req.logout();
res.redirect('/'); 

--> thirdly i faced issue of 
"Login sessions require session support. Did you forget to use express-session middleware?"

here i needed to use the new npm package `express-session` and need to add code to use express-session as middleware. 
code i need to add:
var session = require('express-session'); 

app. app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
cookie: { secure: true } }));
}));

doc link: https://www.passportjs.org/concepts/authentication/sessions/
More info about session: https://medium.com/passportjs/fixing-session-fixation-b2b68619c51d
one more workaround mentioned in github: https://github.com/jaredhanson/passport/issues/939