Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miyamotodev123/a5b61001c5d47758506a to your computer and use it in GitHub Desktop.
Save miyamotodev123/a5b61001c5d47758506a to your computer and use it in GitHub Desktop.
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