Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. router.post('/poster', async (req, res) => {
  2.   var saltRounds = 8;
  3.   var prepassword = req.body.password
  4.   bcrypt.genSalt(saltRounds, function(err, salt) {
  5.       bcrypt.hash(prepassword, salt, function(err, hash) {
  6.           console.log(hash)
  7.           db.any("insert into users (email, username, password)\
  8.                    values($1, $2, $3)", ['yeeeseer', req.body.username.toString(), hash])
  9.  
  10.       });
  11.   });
  12.   res.send('it worked, figure out error message later')
  13.  
  14. });
  15.  
  16. async function hashPass(hashPass){
  17.   var saltRounds = 8;
  18.   bcrypt.genSalt(saltRounds, function(err, salt) {
  19.       bcrypt.hash(hashPass, salt, function(err, hash) {
  20.           console.log(hash)
  21.           //db.any("insert into users (email, username, password)\
  22.             //        values($1, $2, $3)", ['yeeeseer', req.body.username.toString(), hash])
  23.             return hash
  24.       });
  25.   });
  26. }
  27.  
  28.   router.post('/poster', async (req, res) => {
  29.     var username = req.body.username.toString()
  30.     var hashedpass = await hashPass(req.body.password)
  31.     db.any("insert into users (email, username, password)\
  32.              values($1, $2, $3)", ['yeeeseer', username, hashedpass])
  33.     res.send('it worked, figure out error message later')
  34.  
  35.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement