Created
December 23, 2015 12:03
-
-
Save vesse/cd57e1695a2ce5852fa6 to your computer and use it in GitHub Desktop.
Passport + info test http://stackoverflow.com/questions/34367361/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
bodyParser = require('body-parser'), | |
passport = require('passport'), | |
LocalStrategy = require('passport-local').Strategy; | |
var app = express(); | |
passport.use(new LocalStrategy(function (username, password, cb) { | |
cb(null, false, {message: 'This can never succeed'}); | |
})); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
app.use(passport.initialize()); | |
app.post('/login', function(req, res, next) { | |
passport.authenticate('local', function(err, user, info) { | |
res.send(info); | |
})(req, res, next); | |
}); | |
var server = require('http').createServer(app); | |
server.listen(3000, function() { | |
console.log('Server listening on 3000'); | |
}); |
Author
vesse
commented
Dec 23, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment