Passport's middleware is built in a way that allows you to use multiple strategies in one passport.authenticate(...)
call.
However, it is defined with an OR order. This is, it will only fail if none of the strategies returned success.
This is how you would use it:
app.post('/login',
passport.authenticate(['local', 'basic', 'passport-google-oauth']), /* this is how */
function(req, res) {
// If this function gets called, authentication was successful.
// `req.user` contains the authenticated user.
res.redirect('/users/' + req.user.username);
});
In other words, the way to use it, is passing an array containing the name of the strategies you want the user to authenticate with.
Also, dont forget to previously set up the strategies you want to implement.
You can confirm this info in the following github files:
Authenticate using either basic or digest in multi-auth example.
Passport's authenticate.js definition
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…