I'm trying to combine a LinkedInStrategy with an existing LocalStrategy (user is already authenticated).
Here is the example from passport docs :
schema.statics.passportLinkedInStrategy = function(token, tokenSecret, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
// To keep the example simple, the user's LinkedIn profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the LinkedIn account with a user record in your database,
// and return that user instead.
return done(null, profile);
});
};
Problem is I don't have access to req.user to check the existing session in this callback.
Any idea on how I could/should do it?
See the section titled "Association in Verify Callback" in the Authorize chapter of the guide.
There is a passReqToCallback option that you can set, which will pass req as the first argument to the verify callback.