Add Login route express validations

This commit is contained in:
Sahat Yalkabov
2014-01-23 22:47:21 -05:00
parent be73f9c62f
commit 11f9c12b1e
2 changed files with 15 additions and 4 deletions

View File

@@ -22,9 +22,9 @@ passport.deserializeUser(function(id, done) {
passport.use(new LocalStrategy({ usernameField: 'email' }, function(email, password, done) {
User.findOne({ email: email }, function(err, user) {
if (!user) return done(null, false, { message: 'No match found for user: ' + email });
if (!user) return done(null, false, { message: 'Email ' + email + ' not found'});
user.comparePassword(password, function(err, isMatch) {
if(isMatch) {
if (isMatch) {
return done(null, user);
} else {
return done(null, false, { message: 'Invalid email or password.' });