Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. login(req, res, next) {
  2. pm.getUsuario(req.body.username, (err, data) => {
  3. if (err) console.log(err);
  4.  
  5. if (!data[0]) {
  6. res.json({ succes: false, message: 'Log-in fallido. Usuario no encontrado.' });
  7. } else {
  8. console.log(data[0]);
  9. //chekeamos si el password coincide!
  10. if (data[0].contraseña != req.body.password) {
  11. res.json({ succes: false, message: 'Log-in fallido. Contraseña equivocada.' });
  12. } else {
  13. //Se retorna la información incluido el token
  14.  
  15. res.json({
  16. succes: true,
  17. message: 'Disfrute su token!',
  18. token: service.createToken(data[0])
  19. });
  20. }
  21. }
  22. });
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement