Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.post('/', function(req, res, next){
- var user = {
- email : req.body.email,
- password : req.body.password,
- passwordConf : req.body.passwordConf
- };
- //
- var password = req.body.password;
- var passwordC = req.body.passwordConf;
- if(password !== passwordC){
- //TODO Throw back error to home page saying passwords don't match, a
- res.render('homepage');
- }
- //Gen salt and Hash
- var salt = bcrypt.genSaltSync(saltRounds);
- var hash = bcrypt.hashSync(password, salt);
- con.connect(function (err) {
- if(err) throw err;
- var sql = `INSERT INTO USERS (email, passHash, active) VALUES ('${user.email}', '${hash}', FALSE);`;
- //var sql = `INSERT INTO USERS (email, passHash, active) VALUES ('${con.escape(user.email)}', '${con.escape(hash)}', FALSE);`;
- con.query(sql, function (err, result) {
- if(err) throw err;
- });
- });
- user.password = hash;
- res.render('info', user);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement