Skookum/passport — comment on commit 3751d2917d08eb64a6e04f2f68f782e3ba8fd98b
File:  line 0
By jaredhanson:

Dropping in to provide a tip, and get some feedback...

First, the tip. I've been using the callback fully within the request middleware. For example:

app.get('/user-data', function(req, res, next) {
passport.authenticate('local', function(err, user, profile) {
if (err) { return next(err) }
if (!user) { return res.redirect('/signin') }
res.json(req.user);
})(req, res, next);
})

in which case, you get access to `req` and `res` via the closure. Admittedly, the docs need clarification on that point.

Often times when this pattern emerges, its reusable and I break it out into utility middleware.

I'm also curious as to what additional information you'd like to see propagate to the callback, both here and the user `verify` callback for the strategy. I personally have some non-trivial use cases that I'm seeking an elegant solution to, but I'd like to get information about other people's usage. Any feedback is appreciated!

Thanks,
Jared