A Mongoose plugin that integrates with Passport and passport-local to provide username and password authentication for Node.js applications. Version 5.0.10 (stable) is actively maintained with regular releases. Key differentiators: adds hash/salt fields automatically, provides static authenticate/serialize/deserialize methods, and supports customizable username fields and password validators. Unlike manual passport-local setup, it manages password hashing and session serialization automatically.
npm install passport-local-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up Mongoose schema with plugin, configures Passport with local strategy, and creates a user. Demonstrates the minimal setup required.
Either migrate hashes or set options.digestAlgorithm to 'sha1'.
Use 'saltLength' instead of 'saltlen'.
Ensure both dependencies are in package.json.
Define username field explicitly if you need custom options like unique index.
Use async/await or .then() instead of callbacks.
Ensure UserSchema.plugin(passportLocalMongoose) is called before mongoose.model('User', UserSchema)Add a username field to schema or set usernameField option in plugin call: UserSchema.plugin(passportLocalMongoose, { usernameField: 'email' })Set mongoose.set('strictQuery', false) if using Mongoose 6Install mongoose: npm install mongoose
Install passport-local: npm install passport-local