correction bug
This commit is contained in:
parent
d1b502c110
commit
51558b193f
|
@ -19,20 +19,18 @@ module.exports=function(req,res,next){
|
||||||
req.session.userName = name;
|
req.session.userName = name;
|
||||||
req.session.authStatus = true;
|
req.session.authStatus = true;
|
||||||
req.session.authMessage = 'OK';
|
req.session.authMessage = 'OK';
|
||||||
|
console.log(name + " SUCESSFULL LOGED");
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
|
console.log(name + " BAD PASSWORD");
|
||||||
req.session.authStatus = false,
|
req.session.authStatus = false,
|
||||||
req.session.authMessage = "BAD PASSWORD";
|
req.session.authMessage = "BAD PASSWORD";
|
||||||
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
if (req.body.password != "") {
|
||||||
if(req.body.password != "")
|
|
||||||
{
|
|
||||||
var users = {
|
var users = {
|
||||||
"userName": req.body.username,
|
"userName": req.body.username,
|
||||||
"pw": passwordProtection(req.body.password)
|
"pw": passwordProtection(req.body.password)
|
||||||
|
@ -41,7 +39,7 @@ module.exports=function(req,res,next){
|
||||||
if (error) {
|
if (error) {
|
||||||
//res.local.stat = 0;
|
//res.local.stat = 0;
|
||||||
res.locals.message = '0';
|
res.locals.message = '0';
|
||||||
console.log("ERROR SQL LOGIN-CONTROLLER : "+console.error);
|
console.log("ERROR SQL LOGIN-CONTROLLER : " + error);
|
||||||
req.session.authStatus = false;
|
req.session.authStatus = false;
|
||||||
req.session.authMessage = 'SQL INSERT ERROR';
|
req.session.authMessage = 'SQL INSERT ERROR';
|
||||||
next();
|
next();
|
||||||
|
@ -49,17 +47,18 @@ module.exports=function(req,res,next){
|
||||||
req.session.userName = name;
|
req.session.userName = name;
|
||||||
req.session.authStatus = true;
|
req.session.authStatus = true;
|
||||||
req.session.authMessage = 'SQL INSERT OK';
|
req.session.authMessage = 'SQL INSERT OK';
|
||||||
|
console.log(name + "SUCESSFULL REGISTER"+req.session.authMessage);
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
req.session.userName = name;
|
req.session.userName = name;
|
||||||
req.session.authStatus = true;
|
req.session.authStatus = true;
|
||||||
req.session.authMessage = 'AUTH WITHOUT REG OK';
|
req.session.authMessage = 'AUTH WITHOUT REG OK';
|
||||||
|
console.log(name + "SUCESSFULL LOGED WITHOUTH PW");
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
4
index.js
4
index.js
|
@ -28,9 +28,7 @@ app.get('/', function(req, res){
|
||||||
res.redirect('/login');
|
res.redirect('/login');
|
||||||
}).get('/login', function(req, res){
|
}).get('/login', function(req, res){
|
||||||
res.render('login');
|
res.render('login');
|
||||||
}).post('/login', function(req,res,next){
|
}).post('/login', loginController, function(req, res){
|
||||||
next();
|
|
||||||
}, loginController, function(req, res){
|
|
||||||
res.send('<!DOCTYPE html><html><body>'+req.session.authMessage+'<br><a href="/">HOME</a></body></html>');
|
res.send('<!DOCTYPE html><html><body>'+req.session.authMessage+'<br><a href="/">HOME</a></body></html>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue