Created
March 26, 2014 18:41
-
-
Save rlemon/9790295 to your computer and use it in GitHub Desktop.
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 passport = require('passport'), | |
LocalStrategy = require('passport-local').Strategy, | |
passwordHash = require('password-hash'), | |
pg = require('pg').native; | |
var connString = ''; | |
var pgsql = new pg.Client(connString); | |
passport.use(new LocalStrategy( | |
function(providedUsername, password, done) { | |
pgsql.query('SELECT * FROM users WHERE username = ?', [providedUsername], function(err, res) { | |
var user = res[0]; | |
if( !user ) { | |
return done(null, false, {message: 'incorrect username'}); | |
} | |
if( !passwordHash.verify( password, user.password ) ) { | |
return done(null, false, {message: 'incorrect password'}); | |
} | |
return done(null, user); | |
}) | |
} | |
)); | |
module.exports = ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment