passport-pin

1.0.0 • Public • Published

passport-pin

Passport strategy for authenticating with a pin

This module lets you authenticate using a pin in your Node.js applications. By plugging into Passport, local authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-pin

Usage

Configure Strategy

The local authentication strategy authenticates users using a username and password. The strategy requires a verify callback, which accepts these credentials and calls done providing a user.

passport.use(new PinStrategy(
  function(pin, done) {
    User.findOne({ pin: pin }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      if (!user.verifyPassword(password)) { return done(null, false); }
      return done(null, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'pin' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.post('/pinlogin', 
  passport.authenticate('local', { failureRedirect: '/login' }),
  function(req, res) {
    res.redirect('/');
  });

Examples

For complete, working examples, refer to the multiple examples included.

Tests

$ npm install
$ npm test

Credits

License

The MIT License

Copyright (c) 2011-2014 Shawn Brinkman

/passport-pin/

    Package Sidebar

    Install

    npm i passport-pin

    Weekly Downloads

    2

    Version

    1.0.0

    License

    none

    Last publish

    Collaborators

    • shawnb457