Advertisement
Guest User

Untitled

a guest
Mar 13th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. exports.createUser = (request, h) => {
  2.  
  3. return bcrypt.hash(request.payload.password, 10).then(hash => {
  4. let user = new User({
  5. email: request.payload.email,
  6. username: request.payload.username,
  7. password: hash,
  8. admin: false
  9. });
  10.  
  11. return user.save()
  12. .then(user => {
  13. return {
  14. _id: user._id,
  15. email: user.email,
  16. username: user.username,
  17. admin: user.admin
  18. };
  19. })
  20. .catch(error => {
  21. throw Boom.badRequest(error);
  22. });
  23.  
  24. })
  25. .catch(error => {
  26. // ide kerül ha a bcrypt szarik be
  27. throw Boom.internal(error);
  28. });
  29.  
  30.  
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement