1.0.0 • Published 10 years ago

passport-local v1.0.0

Weekly downloads
442,468
License
-
Repository
github
Last release
10 years ago

passport-local

Build Coverage Quality Dependencies Tips

Passport strategy for authenticating with a username and password.

This module lets you authenticate using a username and password 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-local

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 LocalStrategy(
  function(username, password, done) {
    User.findOne({ username: username }, 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 'local' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.post('/login', 
  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 Jared Hanson [http://jaredhanson.net/](http://jaredhanson.net/)

@halon/web-uiteach_and_learnwebux-auth@raggesilver/rage-logintest_gatewayhub@paintzen/security@back4app/back4app@italk/test1codeberry-data-miningrsn-node-corehadith-appconttanodehal@klues/superlogin@awanisius/just-login@sample-vst/apigamestackdrbookinlayer@schm-dt/apianna-authnando-auth@md-app/loopback-component-oauth2-serverfirmanza-commonssuhie-connectapp14-vivesintabaco-serverian-serverjupiter-menu-handler@milesartemius/web-lab3bookipi-servertransmetrix-payments@klearthinkk/yu-nestjs-tempuni-comms-gateway@tpboard/libsnest-auth-graphql-redispblibsaloha.tech-backend@wong-bejo/apimeen-cmsngx-express-passport-setupaxiuss-systemtzar-coreers_flowtagbackend@prolog-school/commons-api-v2@softwits/user-authentication-authorizationfull-autheves-api@sinny777/microservices-core@secretboy/auth@fof-nestjs/corenest-user-modnest-user-module@weblinuz/pam@weblinuz/session@cloady/pam@cloady/sessionstrapi-new-admincancerbero-backendcampybot-yonetim-web-panelmomenta-backendsynaptix.jslab3_pyapg-api-serveranysols-security-serviceavrorajs@dslaporte/luizalabs_commons_nestjs@plt4rm/security@anysols/anysols-security-service@anysols/security-servicesurf2gather-backendnocodb1nolayjseyezon@tech-lab/node-mvcbibletext.cocore-new-sgdevaptexpress-objection-starter@adapttive/strapi-admintill-auth@dicta-io/storage-noderc-guardpdxdeploy-v3.1.3venue-backendcroket_mainpriceitbe-core-testbeyondnet.nestjssharedlibbeyondnet.nestjssharedlib.busnest-toolsmoonbase-scenariospdq-coretdp-datamodeler@liquicode/lib-server-kitberserk-adminblitz-authsmart-paymentssmart-walletsfx-services-authentication@infinitebrahmanuniverse/nolb-passport-l
1.0.0

10 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago