Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/passport-local

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/passport-local

TypeScript definitions for passport-local 1.0.0

  • 1.0.21-alpha
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
160K
decreased by-55.9%
Maintainers
1
Weekly downloads
 
Created

What is @types/passport-local?

@types/passport-local provides TypeScript type definitions for the passport-local strategy, which is a Passport.js strategy for authenticating with a username and password.

What are @types/passport-local's main functionalities?

LocalStrategy

This feature allows you to define a local authentication strategy using a username and password. The code sample demonstrates how to set up the LocalStrategy with Passport.js.

const LocalStrategy = require('passport-local').Strategy;
const passport = require('passport');

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, { message: 'Incorrect username.' }); }
      if (!user.validPassword(password)) { return done(null, false, { message: 'Incorrect password.' }); }
      return done(null, user);
    });
  }
));

Serialization and Deserialization

This feature allows you to serialize and deserialize user information to maintain authentication state across HTTP requests. The code sample shows how to implement these methods with Passport.js.

passport.serializeUser(function(user, done) {
  done(null, user.id);
});

passport.deserializeUser(function(id, done) {
  User.findById(id, function (err, user) {
    done(err, user);
  });
});

Middleware Integration

This feature allows you to integrate Passport.js middleware into an Express application. The code sample demonstrates how to set up session management and authentication routes.

const express = require('express');
const passport = require('passport');
const app = express();

app.use(require('express-session')({ secret: 'secret', resave: false, saveUninitialized: false }));
app.use(passport.initialize());
app.use(passport.session());

app.post('/login', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login' }));

Other packages similar to @types/passport-local

FAQs

Package last updated on 20 May 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc