{"size": 1069, "ext": "js", "max_stars_repo_path": "app/controllers/LoginController.js", "max_stars_repo_name": "bluesky777/Electron-votar", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/controllers/LoginController.js", "max_issues_repo_name": "bluesky777/Electron-votar", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/controllers/LoginController.js", "max_forks_repo_name": "bluesky777/Electron-votar", "max_forks_repo_forks_event_min_datetime": "2018-10-25T23:17:41.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-25T23:17:41.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 19.0892857143, "max_line_length": 68, "alphanum_fraction": 0.5575304022}
var express         = require('express');
var router          = express.Router();
var db              = require('../conexion/connWeb');



// Enrutadores
router.route('/logout').put(putLogout)
router.route('/login').post(postLogin)
router.route('/verificar').post(postVerificar);

    


// Funciones
function putLogout(req, res) {
    
    consulta 	= `SELECT * FROM ws_idiomas where deleted_at is null`;
    connection.query(consulta, function (error, result) {
        
        res.json( result );
        
    });
}

function postLogin(req, res) {
    
    User = require('../conexion/Models/User');
    
    User.login(req.body).then(function(user){
            
         console.log(user);

        //return User.datos_usuario_logueado(user);
        return user;
        
    }, function(r2){
        
        console.log(r2);
        res.status(400).send({ error: r2 })
        
    }).then(function(user){
        
        res.send(user);
        
    })
    
    
}


function postVerificar(req, res) {
    //handle POST route here
}

module.exports = router;