Login with bad credentials fails correctly
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
c2ae12df5c
commit
3c4d12c176
@ -506,10 +506,21 @@
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
this.user = null;
|
||||
window.fetch("api/v1/users/login", function(error, xhr) {
|
||||
this.loading = false;
|
||||
this.password = "";
|
||||
var user;
|
||||
if (error) {
|
||||
this.user = null;
|
||||
this.$.toast.text = error;
|
||||
this.$.toast.setAttribute("error", true);
|
||||
this.$.toast.updateStyles();
|
||||
this.$.toast.show();
|
||||
console.error("Invalid login information.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
user = JSON.parse(xhr.responseText);
|
||||
} catch(___) {
|
||||
@ -518,7 +529,9 @@
|
||||
this.$.toast.updateStyles();
|
||||
this.$.toast.show();
|
||||
console.error("Unable to parse user information");
|
||||
return;
|
||||
}
|
||||
|
||||
this.user = user;
|
||||
}.bind(this), null, "POST", { u: this.username, p: this.password });
|
||||
},
|
||||
|
@ -49,7 +49,7 @@ router.post("/login", function(req, res) {
|
||||
return ldapPromise(username, password).then(function(user) {
|
||||
return user;
|
||||
}).catch(function() {
|
||||
let query = "SELECT * FROM users WHERE username=:username";
|
||||
let query = "SELECT * FROM users WHERE uid=:username";
|
||||
return userDB.sequelize.query(query, {
|
||||
replacements: {
|
||||
username: username,
|
||||
@ -64,13 +64,13 @@ router.post("/login", function(req, res) {
|
||||
});
|
||||
}).then(function(user) {
|
||||
if (!user) {
|
||||
console.log(username + " not found: " + error);
|
||||
console.log(username + " not found.");
|
||||
req.session.user = {};
|
||||
return res.status(401).send("Invalid login credentials");
|
||||
}
|
||||
|
||||
console.log("Logging in as " + user.displayName);
|
||||
|
||||
|
||||
req.session.user = {
|
||||
name: user.displayName,
|
||||
mail: user.mail,
|
||||
|
Loading…
x
Reference in New Issue
Block a user