How does Passport handle authorization?
Authorization is handled by calling passport.authorize(). If the authorization is granted, the result by the verify callback shall be assigned to the req.account.
Here's how authorization of a Twitter account is handled in Passport.
Example
app.get('/connect/twitter',
passport.authorize('twitter-authz', { failureRedirect: '/account' })
);
app.get('/connect/twitter/callback',
passport.authorize('twitter-authz', { failureRedirect: '/account' }),
function(req, res) {
var user = req.user;
var account = req.account;
account.userId = user.id;
account.save(function(err) {
if (err) { return self.error(err); }
self.redirect('/');
});
}
);