in api/services/passport.js [222:252]
passport.callback = function (req, res, next) {
var provider = req.param('provider', 'local')
, action = req.param('action');
// Passport.js wasn't really built for local user registration, but it's nice
// having it tied into everything else.
if (provider === 'local' && action !== undefined) {
if (action === 'register' && !req.user) {
this.protocols.local.register(req, res, next);
}
else if (action === 'connect' && req.user) {
this.protocols.local.connect(req, res, next);
}
else if (action === 'disconnect' && req.user) {
this.disconnect(req, res, next);
}
else {
next(new Error('Invalid action'));
}
} else {
if (action === 'disconnect' && req.user) {
this.disconnect(req, res, next) ;
} else {
// The provider will redirect the user to this URL after approval. Finish
// the authentication process by attempting to obtain an access token. If
// access was granted, the user will be logged in. Otherwise, authentication
// has failed.
this.authenticate(provider, next)(req, res, req.next);
}
}
};