Accessing request object in serializeUser function in passport.js

I am writing simple app using node.js and passport.js for auth.

Can I get access to the request object in serializeUser?

It's actually pretty simple: req is added as the first parameter

passport.deserializeUser(function(req, id, done) {...

https://github.com/jaredhanson/passport/issues/111

If you do req.res.render('whatever' it works.

I think yttrium and laggingreflex questions are slightly different:

To answer yttrium:

To access the request object you have to do it inside an express middleware that will deal with authorization of your resource.

function authMethod(req, res, next) {
    if (req.isAuthenticated()) 
    { 
        console.log(req.user);
        return next(); 
    }
    res.status(401).send({user:undefined});
}
app.get('/',authMethod,function(req,response)
{
     res.status(200).send("OK");
}

If you have done the configuration right, Passaport will make modifications to your request object, so you can access the user information with req.user. You also have a method, req.isAuthenticated(), to check if the third-party auth was succeeded.

To answer laggingreflex:

You can't access the request object inside passport.deserializeUser and passport.serializeUser because those methods are made to deal with the serialization of the user information inside a session (Look at the github explanation). Those methods receive an object and a function as parameters. On serializeUser the first parameter is an object with user information that you will serialize and pass to the donefunction (callback). On deserializeUser the first parameter is an object that was serialized that you have to do the reverse operation.