Give proper "login incorrect" error on signin page

master
Skylar Ittner 5 years ago
parent 709540eee6
commit 332ed3e38a

@ -87,16 +87,16 @@ function callAPIRawResponse(action, data, success, failure) {
} }
switch (textStatus) { switch (textStatus) {
case "timeout": case "timeout":
failure("Couldn't connect to the server (timeout)."); failure("Couldn't connect to the server (timeout).", xhr);
break; break;
case "error": case "error":
failure("Couldn't connect to the server (error)."); failure("Couldn't connect to the server (error).", xhr);
break; break;
case "parseerror": case "parseerror":
failure("The server sent a malformed response."); failure("The server sent a malformed response.", xhr);
break; break;
default: default:
failure("Couldn't connect to the server."); failure("Couldn't connect to the server.", xhr);
} }
} }
}); });

@ -11,7 +11,7 @@ $('#username').on("keyup", function () {
function checkAndSave(username, password) { function checkAndSave(username, password) {
app.preloader.show(); app.preloader.show();
callAPI("ping", { callAPIRawResponse("ping", {
username: username, username: username,
password: password password: password
}, function (data) { }, function (data) {
@ -32,9 +32,13 @@ function checkAndSave(username, password) {
app.preloader.hide(); app.preloader.hide();
app.dialog.alert(msg, "Error"); app.dialog.alert(msg, "Error");
}); });
}, function (msg) { }, function (msg, xhr) {
app.preloader.hide(); app.preloader.hide();
app.dialog.alert(msg, "Error"); if (xhr.status == 401) {
app.dialog.alert("Login incorrect.", "Error");
} else {
app.dialog.alert(msg, "Error");
}
}); });
} }
@ -43,4 +47,10 @@ function setupAccount() {
var password = $("#password").val(); var password = $("#password").val();
checkAndSave(username, password); checkAndSave(username, password);
} }
$("#password").on("keyup", function (evt) {
if (evt.keyCode == 13) {
setupAccount();
}
})
Loading…
Cancel
Save