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;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
this.user = null;
|
||||||
window.fetch("api/v1/users/login", function(error, xhr) {
|
window.fetch("api/v1/users/login", function(error, xhr) {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.password = "";
|
this.password = "";
|
||||||
var user;
|
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 {
|
try {
|
||||||
user = JSON.parse(xhr.responseText);
|
user = JSON.parse(xhr.responseText);
|
||||||
} catch(___) {
|
} catch(___) {
|
||||||
@ -518,7 +529,9 @@
|
|||||||
this.$.toast.updateStyles();
|
this.$.toast.updateStyles();
|
||||||
this.$.toast.show();
|
this.$.toast.show();
|
||||||
console.error("Unable to parse user information");
|
console.error("Unable to parse user information");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}.bind(this), null, "POST", { u: this.username, p: this.password });
|
}.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 ldapPromise(username, password).then(function(user) {
|
||||||
return user;
|
return user;
|
||||||
}).catch(function() {
|
}).catch(function() {
|
||||||
let query = "SELECT * FROM users WHERE username=:username";
|
let query = "SELECT * FROM users WHERE uid=:username";
|
||||||
return userDB.sequelize.query(query, {
|
return userDB.sequelize.query(query, {
|
||||||
replacements: {
|
replacements: {
|
||||||
username: username,
|
username: username,
|
||||||
@ -64,13 +64,13 @@ router.post("/login", function(req, res) {
|
|||||||
});
|
});
|
||||||
}).then(function(user) {
|
}).then(function(user) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
console.log(username + " not found: " + error);
|
console.log(username + " not found.");
|
||||||
req.session.user = {};
|
req.session.user = {};
|
||||||
return res.status(401).send("Invalid login credentials");
|
return res.status(401).send("Invalid login credentials");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Logging in as " + user.displayName);
|
console.log("Logging in as " + user.displayName);
|
||||||
|
|
||||||
req.session.user = {
|
req.session.user = {
|
||||||
name: user.displayName,
|
name: user.displayName,
|
||||||
mail: user.mail,
|
mail: user.mail,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user