Passport strategy for authenticating with custom logic.
This module lets you authenticate using custom logic in your Node.js applications. By plugging into Passport, custom authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
$ npm install passport-custom The custom authentication strategy authenticates users by custom logic. The strategy requires a verify callback, which is where the custom logic goes and calls done providing a user.
passport.use(new CustomStrategy( function(done) { User.findOne({ uid: 1 }, function (err, user) { if (err) { return done(err); } if (!user) { return done(null, false); } return done(null, user); }); } )); Use passport.authenticate(), specifying the 'custom' strategy, to authenticate requests.
For example, as route middleware in an Express application:
app.post('/login', passport.authenticate('custom', { failureRedirect: '/login' }), function(req, res) { res.redirect('/'); }); For complete, working examples, refer to the multiple examples included.
$ npm install $ npm test Copyright (c) 2011-2014 Michael Bell




