Advertisement
rodrigofbm

userControllers

Apr 18th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports.createUser = (application, req, res) => {
  2.     let dadosForm = req.body;
  3.     const {User} = require('../models/Schemas/userSchema');
  4.     const userModel = new application.app.models.userModel(User);
  5.  
  6.     req.assert('email', 'Digite um e-mail válido.').isEmail();
  7.  
  8.     let errors = req.validationErrors();
  9.  
  10.     if(errors) return res.status(402).send(errors);
  11.  
  12.     userModel.createUser(res, dadosForm);
  13.    
  14. }
  15.  
  16. module.exports.createUserInfos = (application, req, res) => {
  17.     let dadosForm = req.body;
  18.     let userId = req.params.userId;
  19.     const {User} = require('../models/Schemas/userSchema');
  20.     const userModel = new application.app.models.userModel(User);
  21.  
  22.     userModel.createUserInfos(res, userId, dadosForm);
  23.    
  24. }
  25.  
  26. module.exports.getUserInfos = (application, req, res) => {
  27.     let userId = req.params.userId;
  28.     const {User} = require('../models/Schemas/userSchema');
  29.     const userModel = new application.app.models.userModel(User);
  30.  
  31.     userModel.getUserInfos(res, userId);
  32.    
  33. }
  34.  
  35. module.exports.authUser = (application, req, res) => {
  36.     let dadosForm = req.body;
  37.     const {User} = require('../models/Schemas/userSchema');
  38.     const userModel = new application.app.models.userModel(User);
  39.     console.log(res)
  40.     console.log(req)
  41.     req.assert('email', 'Digite um e-mail válido.').isEmail();
  42.  
  43.     let errors = req.validationErrors();
  44.  
  45.     if(errors) {
  46.         res.status(402).send(errors);
  47.         return;
  48.     }
  49.  
  50.     userModel.authUser(res, dadosForm);
  51.    
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement