SHARE
TWEET

Untitled

a guest Dec 10th, 2018 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /
  2.  
  3. / Register Form POST
  4. const bcrypt = require('bcryptjs');
  5.     router.post('/register', (req, res) => {
  6.         const newUser = newUser ({
  7.             name: req.body.name,
  8.             surname: req.body.surname,
  9.             email: req.body.email,
  10.             password: req.body.password
  11.         });
  12.         bcrypt.genSalt(10, (err, salt) => {
  13.             bcrypt.hash(newUser.password, salt, (err, hash) => {
  14.                 if(err) throw err;
  15.                 newUser.password = hash;
  16.                 newUser.save()
  17.                     .then(user => {
  18.                         req.flash('success msg', 'Vous ĂȘtes maintenant enregistrĂ© et pouvez vous connecter.');
  19.                         res.redirect('/app');
  20.                     })
  21.                     .catch(err => {
  22.                         console.log(err);
  23.                         return;
  24.                     });
  25.             });
  26.         });
  27.     });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top