passport-local-sequelize
Advanced tools
Weekly downloads
Readme
Passport-Local Sequelize is a Sequelize plugin that simplifies building username and password login with Passport
This plugin is heavily inspired by Passport-Local Mongoose plugin.
$ npm install passport-local-sequelize
/* /models/user.js */
// Require all the stuff
var Sequelize = require('sequelize'),
passportLocalSequelize = require('passport-local-sequelize');
// Setup sequelize db connection
var mydb = new Sequelize('mydb', 'myuser', 'mypass', {
dialect: 'sqlite',
storage: 'mydb.sqlite'
});
// A helper to define the User model with username, password fields
var User = passportLocalSequelize.defineUser(mydb, {
favoriteColor: Sequelize.STRING
});
// --- OR ---
// Define a User yourself and use attachToUser
var User = mydb.define('User', {
nick: Sequelize.STRING,
myhash: Sequelize.STRING,
mysalt: Sequelize.STRING
});
passportLocalSequelize.attachToUser(User, {
usernameField: 'nick',
hashField: 'myhash',
saltField: 'mysalt'
});
module.exports = User;
Here's how to hook it all up to passport in your express app.
var express = require('express'),
passport = require('passport'),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
User = require('./models/user'),
app = express();
app.use(bodyParser());
app.use(require('connect-multiparty')());
app.use(cookieParser());
app.use(session({ secret: 'super-secret' }));
app.use(passport.initialize());
app.use(passport.session());
passport.use(User.createStrategy());
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
FAQs
Sequelize plugin that simplifies building username and password login with Passport
The npm package passport-local-sequelize receives a total of 431 weekly downloads. As such, passport-local-sequelize popularity was classified as not popular.
We found that passport-local-sequelize demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.