0.4.1 • Published 12 years ago
lox v0.4.1
Lox
Lox is a tiny mongoose based authentication middleware for Express.
Lox is written in coffeescript
Installation
npm install lox
Usage
# Start by adding as Express middleware
mongoDb = 'mongodb://user:password@staff.mongohq.com:1234/whatever'
app = express.createServer()
# Make sure to add it after session middleware
app.use express.session(secret: "234asldkn2naodufnu4n")
app.use lox.middleware(mongoDb)
# Create a user
lox.create email, password, (err) ->
# err != undefined if user could not be created
# Delete a user
lox.destroy email, (err, user) ->
# user.lastWords()
# Get list of all users
lox.find (err, users) ->
# do something with users array
# Get access to logged in user
app.get '/who', (req, res) ->
res.send req.user or "No user logged in"
# Create session (login)
app.get '/login', (req, res, next) ->
email = req.params.email
password = req.params.password
req.login email, password, (err, user) ->
if user then res.send "logged in as #{user.email}"
else res.send "not logged in"
# Destroy session (logout)
app.get '/logout', (req, res, next) ->
req.logout -> res.redirect '/'
Contributing to lox
- Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
- Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
- Fork the project
- Start a feature/bugfix branch
- Commit and push until you are happy with your contribution
- Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
Copyright © 2012 Marcel Miranda. See LICENSE for further details.
0.4.1
12 years ago
0.4.0
12 years ago
0.3.4
12 years ago
0.3.3
12 years ago
0.3.2
12 years ago
0.3.1
12 years ago
0.3.0
12 years ago
0.2.6
12 years ago
0.2.5
12 years ago
0.2.4
12 years ago
0.2.3
12 years ago
0.2.2
12 years ago
0.2.1
12 years ago
0.2.0
12 years ago
0.1.4
12 years ago
0.1.3
12 years ago
0.1.2
12 years ago
0.1.0
12 years ago