Guest User

Untitled

a guest
Oct 1st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. exports.post = async (req, res, next) => {
  2. const Email = req.body.Email;
  3. const Passw = req.body.Password;
  4. if(fluentValidation.validateEmail(Email) && fluentValidation.isValidLength(Passw)){
  5. try {
  6. await sqlService.SignUpUser(Email,Passw,res,req);
  7. } catch (error) {
  8. console.log(error);
  9. }
  10. }else{
  11. res.status(400).send({
  12. Error : "Email invalid"
  13. });
  14. }
  15. }
  16.  
  17. const pool = sql.createPool ({
  18. connectionLimit : 10,
  19. host: '0.0.0.0',
  20. user:'foo',
  21. password : 'foo',
  22. database : 'foo'
  23. });
  24.  
  25.  
  26. module.exports.SignUpUser = async (email,password,res,req) =>{
  27. pool.getConnection(function(err,connection){
  28. if(err){
  29. console.log(err);
  30. }else{
  31. connection.query(`select email from user where email = '${email}'`, function (error, results, fields){
  32. if(results.length < 1){
  33. let date = dateT.getdate();
  34. let guid = uuid();
  35. let etoken = uuid();
  36. connection.query(`INSERT INTO e(e,e,e,e,e) VALUES ('${e}','${e}','${e}','${e}','${e}')`, function (error, results, fields){
  37. if(err){
  38. console.log(err);
  39. }else{
  40. res.status(201).send();
  41. emailService.send(req.body.Email,'Bem vindo ao e',url.buildUrl(req.headers.host,'/validate/'+ etoken));
  42. }
  43. })
  44. }else{
  45. res.status(409).send();
  46. }
  47. });
  48. connection.release();
  49. }
  50. });
  51. }
Add Comment
Please, Sign In to add comment