Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.post = async (req, res, next) => {
- const Email = req.body.Email;
- const Passw = req.body.Password;
- if(fluentValidation.validateEmail(Email) && fluentValidation.isValidLength(Passw)){
- try {
- await sqlService.SignUpUser(Email,Passw,res,req);
- } catch (error) {
- console.log(error);
- }
- }else{
- res.status(400).send({
- Error : "Email invalid"
- });
- }
- }
- const pool = sql.createPool ({
- connectionLimit : 10,
- host: '0.0.0.0',
- user:'foo',
- password : 'foo',
- database : 'foo'
- });
- module.exports.SignUpUser = async (email,password,res,req) =>{
- pool.getConnection(function(err,connection){
- if(err){
- console.log(err);
- }else{
- connection.query(`select email from user where email = '${email}'`, function (error, results, fields){
- if(results.length < 1){
- let date = dateT.getdate();
- let guid = uuid();
- let etoken = uuid();
- connection.query(`INSERT INTO e(e,e,e,e,e) VALUES ('${e}','${e}','${e}','${e}','${e}')`, function (error, results, fields){
- if(err){
- console.log(err);
- }else{
- res.status(201).send();
- emailService.send(req.body.Email,'Bem vindo ao e',url.buildUrl(req.headers.host,'/validate/'+ etoken));
- }
- })
- }else{
- res.status(409).send();
- }
- });
- connection.release();
- }
- });
- }
Add Comment
Please, Sign In to add comment