Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. if (errors) {
  2. res.render('index', {
  3. errors: errors
  4. });
  5. } else {
  6. bcrypt.hash(newUser.password, saltRounds, function (err, hash) {
  7. if (err) {
  8. // console.log(err)
  9. } else {
  10. here
  11.  
  12. Possibly unhandled rejection: <!DOCTYPE html>
  13. <html ng-app="mainApp">
  14.  
  15. <head>
  16. <meta charset="utf-8">
  17.  
  18. router.post('/create', function (req, res, next) {
  19.  
  20. var newUser = {
  21. login: req.body.login,
  22. password: req.body.password,
  23. }
  24.  
  25. req.checkBody('login', 'Login is required').notEmpty();
  26. req.checkBody('password', 'Password is required').notEmpty();
  27.  
  28. var errors = req.validationErrors();
  29.  
  30. if (errors) {
  31. res.render('index', {
  32. errors: errors
  33. });
  34. } else {
  35. bcrypt.hash(newUser.password, saltRounds, function (err, hash) {
  36. if (err) {
  37. // console.log(err)
  38. } else {
  39. newUser.password = hash;
  40. var user = new User(newUser);
  41. user.save()
  42. .then(function (User) {
  43. res.send(User);
  44. })
  45. .catch((err) => {
  46. console.log(err)
  47. })
  48. }
  49. });
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement