Advertisement
nerdIt24

Untitled

Nov 21st, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. router.post("/verify/:token", (req, res) => {
  2. const { token } = req.params;
  3. console.log(typeof req.params);
  4.  
  5. const errors = {};
  6.  
  7. database
  8. .returning(["email", "emailverified", "tokenusedbefore"])
  9. .from("users")
  10. .where({ token: token, tokenusedbefore: "f" })
  11. .update({ emailverified: "t", tokenusedbefore: "t" })
  12. .then(data => {
  13. console.log(data.length);
  14. console.log(data);
  15.  
  16. if (data.length > 0) {
  17. // Return an email verified message
  18. res.json("Email verified! Please login to access your account");
  19. } else {
  20. database
  21. .select("email", "emailverified", "tokenusedbefore")
  22. .from("users")
  23. .where("token", token)
  24. .then(check => {
  25. console.log("check", check);
  26. if (check.length > 0) {
  27. console.log("check length is 0");
  28. }
  29. });
  30. }
  31. });
  32. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement