Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. bcrypt.hash(ctx.request.body.pass, 10).then(hash => {
  2. var userData = {
  3. email: ctx.request.body.email,
  4. username: ctx.request.body.username,
  5. name: ctx.request.body.name,
  6. lastname: ctx.request.body.lastname,
  7. pass: hash,
  8. }
  9. console.log("create user...");
  10. console.log(userData);
  11. ctx.mongo.collection("users").insert(userData).then(() => {
  12. ctx.body = JSON.stringify({
  13. success: "createdUser"
  14. });
  15. }).catch(err => {
  16. ctx.body = JSON.stringify({
  17. error: err,
  18. });
  19. });
  20.  
  21. }).catch(err => {
  22. console.log(err);
  23. ctx.body = JSON.stringify({
  24. error: err,
  25. });
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement