express-mongoose-auth
Username/password auth for express apps with Mongoose-backed user models
Getting Started
Install the module with npm (soon...)
Model Setup
express-mongoose-auth assumes you have some sort of User model backed by Mongoose.
Define your schema as normal. Note that express-mongoose-auth requires you to have salt and hashed_password String attributes:
var mongoose = ; var userSchema = email: String hashed_password: String salt: String
Before defining the model with mongoose#model:
var auth = ; auth;
This will define methods to facilitate password hashing, validation, etc. Finally, declare the model as normal:
mongoose;
Route setup
In your routes, first you'll want to log users in:
var app = ; app;... app;
Then, in your routes you want to require authentication in:
var { // This generates standard express middleware with a signature of (req, res, next) return auth;}; app
** TODO
- Use bcrypt
- Entitlements support
- Lots