Advertisement
Guest User

Untitled

a guest
Jun 21st, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. passport.use('local-signup', new LocalStrategy({
  2. usernameField: 'username',
  3. passwordField: 'password',
  4. passReqToCallback: true
  5. }, function(req, username, password, cb) {
  6. process.nextTick(function() {
  7. User.findOne({
  8. username: username
  9. }, function(err, data) {
  10. if (err)
  11. return cb(err)
  12. if (data)
  13. return cb(null, false, req.flash('signupMessage', 'That username is already taken.'));
  14.  
  15.  
  16. // Insert method goes here.
  17. var newUser = new User()
  18.  
  19. newUser.username = username
  20. newUser.password = password
  21.  
  22. newUser.save(function(err){
  23. if(err) throw err
  24. return cb(null, newUser);
  25. })
  26. });
  27. })
  28. }));
  29.  
  30. <input type="text" name="username" placeholder="username"/>
  31. <input type="text" name="fullname" placeholder="fullname" />
  32. <input type="text" name="emaill" placeholder="email"/>
  33. <input type="text" name="password" placeholder="password"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement