login completado

This commit is contained in:
2022-11-04 12:40:22 -05:00
parent ffd9c9f897
commit 0ee3289bac
2 changed files with 13 additions and 5 deletions

View File

@@ -26,8 +26,9 @@ controlador.app_login = (req, res) => {
};
controlador.auth = (req, res) => {
console.log(req.body);
var pwd = stringTo_md5(req.body.password);
req.getConnection((err, conn) => {
conn.query(`SELECT * FROM usuarios WHERE n_sesion = ?`,[req.body.usuario],(err,rows)=>{
conn.query(`SELECT * FROM usuarios WHERE n_sesion = ? and clave=?`,[req.body.usuario,pwd],(err,rows)=>{
if(err){
//res.json(err);
res.json("No Autorizado");
@@ -35,11 +36,12 @@ controlador.auth = (req, res) => {
try{
if(rows.length>0){
//res.json({sision:"exitosa"});
console.log(rows);
res.render('panel_control');
}
}catch(e){
res.render('login.ejs');
res.render('login');
next();
}
}
@@ -48,7 +50,13 @@ controlador.auth = (req, res) => {
//res.render('');
};
//********* APP-SIGMA ********//
function stringTo_md5(data_string){
var crypto = require('crypto');
const md5 = crypto.createHash('md5').update(data_string).digest('hex');
console.log("MD5: ", md5);
return md5;
}
//********* APP-PEDIDOS-SIGMA ********//
controlador.app_sigma = (req, res) => {
res.render('app_pedidos');
};