passport.js - Node.js passport skips strategy -
this coffee-script passport implementation looks examples me fails every time , never prints "trying out strategy". redirected "/fail". tried naming strategy executing in (req, res, next) handler. verified form posted sent username , password in fields , tried renaming them mapping in strategy according examples no avail. tips on i'm overlooking?
pass = require 'passport' strat = require('passport-local').strategy exp = require 'express' app = exp.createserver() # configure strategy pass.use new strat (username, password, done) -> #logic find user console.log("trying out strategy") user = {nm:username,ps:password} done(null,user) app.configure () -> app.use (req,res,next) -> console.log("got req") next() app.use pass.initialize() ops = { failureredirect: '/fail' } app.post '/auth', pass.authenticate('local',ops), (req, res, next) -> console.log "what here" app.listen 1337 solution modify express configuration:
app.configure () -> app.use exp.bodyparser()
turns out problem due ignorance of express. sending username , password wasn't parsing - app.configure requires express.bodyparser() in order utilize strategies.
Comments
Post a Comment