Skip to content

Instantly share code, notes, and snippets.

@vesse
Created December 23, 2015 12:03
Show Gist options
  • Save vesse/cd57e1695a2ce5852fa6 to your computer and use it in GitHub Desktop.
Save vesse/cd57e1695a2ce5852fa6 to your computer and use it in GitHub Desktop.
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');
});
@vesse
Copy link
Author

vesse commented Dec 23, 2015

$ curl -X POST -H 'Content-type: application/json' -d '{"username": "none", "password": "wrong"}' http://localhost:3000/login 
{"message":"This can never succeed"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment