Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

passport-local-fluxible

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-local-fluxible

Fluxible compatible Local Passport strategy

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

passport-local-fluxible

Fluxible compatible Passport strategy for authenticating with a username and password.

This is a port of the official local strategy to make it work with the Fluxible framework.

Install

$ npm install passport-local-fluxible

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:

module.exports = {
  name: 'login',
  create: function(req, resource, params, body, config, done) {
    passport.authenticate('local', function(err, user, info) {
      if(err || !user) {
        debug('Auth failed');
        return done(err);
      }

      req.logIn(user, function(err2) {
        if(err2) {
          debug('Login failed');
          return done(err2);
        }

        return done(err, {
          user: user
        });
      });
    })(req, req.res, done);
  }
};

Credits

  • Jared Hanson for the original passport-local
  • Tommy Leunen

License

The MIT License

Keywords

passport

FAQs

Package last updated on 28 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts