Advertisement
utrolig

Untitled

Jun 3rd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is the route... So I send a POST to localhost/api/user/new with the body...
  2.  
  3. apiRoutes.post('/user/new', function(req, res) {
  4.         var user = {
  5.         name: req.body.name,
  6.         username: req.body.username,
  7.         password: req.body.password,
  8.         email: req.body.email,
  9.         created_at: db.fn.now(),
  10.         updated_at: db.fn.now(),
  11.     };
  12.  
  13.     hashPass.new(user.password, function(result){
  14.         user.password = result;
  15.         console.log(result);
  16.     })
  17. });
  18.  
  19.  
  20. // This is the hashPass.new function
  21. new: function(password, callback){
  22.         var hashed;
  23.         bcrypt.hash(password, 10, function(err, hash){
  24.             return hashed;
  25.         });
  26.         callback();
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement