Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Local Strategy for Towerjs
localStrategy: (options) ->
app = Tower.Application.instance()
app.get "/logout", (request, response) ->
response.redirect "/" "/login", (request, response, next) ->
console.log 'authenticating....'
passport.authenticate("local", (err, user, info) ->
return next(err) if err
unless user
return response.redirect("/")
request.logIn user, (err) ->
return next(err) if err
)(request, response, next)
Strategy = require("passport-local").Strategy
passport.use new Strategy (username, password, done) ->
console.log username
App.User.where(name: username).first (err, user) ->
done(err) if err
console.log user
done null, user
catch error
error.message += " (#{name})"
throw error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment