userCtrl 2/3

PHOTO EMBED

Tue Sep 07 2021 22:00:56 GMT+0000 (Coordinated Universal Time)

Saved by @devdave

// [2] middleWares Functions
// -
exports.signup = (req, res, next) => {
  bcrypt
    .hash(req.body.password, 10)
    .then((hash) => {
      const user = new User({
        email: req.body.email,
        password: hash,
      });
      user
        .save()
        .then(() => res.status(201).json({ message: "User créé !" }))
        .catch((error) => res.status(400).json({ error }));
    })
    .catch((error) => res.status(500).json({ error }));
};
content_copyCOPY