mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-31 18:11:54 +08:00
fixed login error on empty username
This commit is contained in:
@@ -18,21 +18,24 @@ function main() {
|
|||||||
|
|
||||||
function __login() {
|
function __login() {
|
||||||
var user = $("user-input").value;
|
var user = $("user-input").value;
|
||||||
var passwd = $("passwd-input").value;
|
if (user.length === 0) {
|
||||||
var body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`;
|
$("user-input").focus();
|
||||||
|
} else {
|
||||||
var http = tools.makeRequest("POST", "/kvmd/auth/login", function() {
|
var passwd = $("passwd-input").value;
|
||||||
if (http.readyState === 4) {
|
var body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`;
|
||||||
if (http.status === 200) {
|
var http = tools.makeRequest("POST", "/kvmd/auth/login", function() {
|
||||||
document.location.href = "/";
|
if (http.readyState === 4) {
|
||||||
} else if (http.status === 403) {
|
if (http.status === 200) {
|
||||||
wm.error("Invalid username or password").then(__tryAgain);
|
document.location.href = "/";
|
||||||
} else {
|
} else if (http.status === 403) {
|
||||||
wm.error("Login error:<br>", http.responseText).then(__tryAgain);
|
wm.error("Invalid username or password").then(__tryAgain);
|
||||||
|
} else {
|
||||||
|
wm.error("Login error:<br>", http.responseText).then(__tryAgain);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}, body, "application/x-www-form-urlencoded");
|
||||||
}, body, "application/x-www-form-urlencoded");
|
__setDisabled(true);
|
||||||
__setDisabled(true);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __setDisabled(disabled) {
|
function __setDisabled(disabled) {
|
||||||
|
|||||||
Reference in New Issue
Block a user