Created
January 6, 2016 04:00
-
-
Save miyamotodev123/a5b61001c5d47758506a 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
User.findOne({ 'local.email' : email }, function(err, user) { | |
// if there are any errors, return the error | |
if (err) | |
return done(err); | |
// check to see if theres already a user with that email | |
if (user) { | |
return done(null, { error: 'That email is already taken.' }); | |
} else { | |
// create the user | |
var newUser = new User(); | |
newUser.local.email = email; | |
newUser.local.password = newUser.generateHash(password); | |
newUser.save(function(err) { | |
if (err) | |
throw err; | |
return done(null, newUser); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment