Advertisement
Guest User

Untitled

a guest
Apr 7th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.createUser = async (req, res, next) => {
  2.     try {
  3.         var newUser = new User(req.body);
  4.  
  5.         // O cadastro de um morador sempre começa como falso, enquanto outros tipos são cadastrados aprovados
  6.         newUser.approvedRegister = (newUser.userType == USER_TYPE_ENUM.RESIDENT ? false : true);
  7.  
  8.         await bcrypt.hash(newUser.password, saltRounds, async (error, hash) => {
  9.             newUser.password = hash;
  10.             newUser = await repository.createUser(newUser);
  11.             res.status(HttpStatusCode.OK).send(newUser);
  12.         });
  13.     } catch (error) {
  14.         res.status(HttpStatusCode.BAD_REQUEST).send({
  15.             error
  16.         });
  17.     }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement