Advertisement
Guest User

Untitled

a guest
Oct 10th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   async register (req, res) {
  2.     if (!_.has(req.body, 'email') || !_.has(req.body, 'password') || !_.has(req.body, 'username')) {
  3.       return res.serverError('No field should be empty')
  4.     } else {
  5.       bcrypt.hash(req.body.password, 10, (err, hash) => {
  6.         if (err) return res.serverError(err)
  7.         let user = await User.create({ username: req.body.username, email: req.body.email, password: hash }).fetch()
  8.         return res.json(user)
  9.       })
  10.     }
  11.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement