prevent login using bad account
This commit is contained in:
parent
3262dcdb67
commit
f3dcf43337
1 changed files with 6 additions and 2 deletions
|
@ -10,7 +10,8 @@ router.post('/auth', function(request, response) {
|
||||||
let user = User.findOne({
|
let user = User.findOne({
|
||||||
name: username, pass: password
|
name: username, pass: password
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
console.log(results.name);
|
if (results !=null) {
|
||||||
|
console.log(results.name);
|
||||||
if (results.name.length > 0) {
|
if (results.name.length > 0) {
|
||||||
request.session.loggedin = true;
|
request.session.loggedin = true;
|
||||||
request.session.username = username;
|
request.session.username = username;
|
||||||
|
@ -20,7 +21,10 @@ router.post('/auth', function(request, response) {
|
||||||
response.send('Incorrect Username and/or Password!');
|
response.send('Incorrect Username and/or Password!');
|
||||||
}
|
}
|
||||||
response.end();
|
response.end();
|
||||||
});
|
} else {
|
||||||
|
response.send('Use a registered username Please.')
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
response.send('Please enter Username and Password!');
|
response.send('Please enter Username and Password!');
|
||||||
response.end();
|
response.end();
|
||||||
|
|
Loading…
Reference in a new issue