fixed login error on empty username

This commit is contained in:
Devaev Maxim
2018-12-16 16:44:42 +03:00
parent 0492ff2e02
commit aa8d0aa01d

View File

@@ -18,9 +18,11 @@ function main() {
function __login() { function __login() {
var user = $("user-input").value; var user = $("user-input").value;
if (user.length === 0) {
$("user-input").focus();
} else {
var passwd = $("passwd-input").value; var passwd = $("passwd-input").value;
var body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`; var body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`;
var http = tools.makeRequest("POST", "/kvmd/auth/login", function() { var http = tools.makeRequest("POST", "/kvmd/auth/login", function() {
if (http.readyState === 4) { if (http.readyState === 4) {
if (http.status === 200) { if (http.status === 200) {
@@ -34,6 +36,7 @@ function __login() {
}, body, "application/x-www-form-urlencoded"); }, body, "application/x-www-form-urlencoded");
__setDisabled(true); __setDisabled(true);
} }
}
function __setDisabled(disabled) { function __setDisabled(disabled) {
$("user-input").disabled = disabled; $("user-input").disabled = disabled;