mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-30 09:31:53 +08:00
logout
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
var wm;
|
||||
|
||||
function main() {
|
||||
if (checkBrowser()) {
|
||||
wm = new WindowManager();
|
||||
|
||||
tools.setOnClick($("login-button"), __login);
|
||||
document.onkeyup = function(event) {
|
||||
$("user-input").onkeyup = $("passwd-input").onkeyup = function(event) {
|
||||
if (event.code == "Enter") {
|
||||
event.preventDefault();
|
||||
__login();
|
||||
}
|
||||
};
|
||||
|
||||
$("user-input").focus();
|
||||
}
|
||||
}
|
||||
@@ -15,17 +20,18 @@ function __login() {
|
||||
var user = $("user-input").value;
|
||||
var passwd = $("passwd-input").value;
|
||||
var body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`;
|
||||
|
||||
var http = tools.makeRequest("POST", "/kvmd/auth/login", function() {
|
||||
if (http.readyState === 4) {
|
||||
if (http.status === 200) {
|
||||
document.location.href = "/";
|
||||
} else if (http.status === 403) {
|
||||
wm.error("Invalid username or password").then(__tryAgain);
|
||||
} else {
|
||||
wm.error("Login error:<br>", http.responseText).then(__tryAgain);
|
||||
}
|
||||
__setDisabled(false);
|
||||
$("passwd-input").focus();
|
||||
$("passwd-input").select();
|
||||
}
|
||||
}, body, "application/x-www-form-urlencoded");
|
||||
http.send();
|
||||
__setDisabled(true);
|
||||
}
|
||||
|
||||
@@ -34,3 +40,9 @@ function __setDisabled(disabled) {
|
||||
$("passwd-input").disabled = disabled;
|
||||
$("login-button").disabled = disabled;
|
||||
}
|
||||
|
||||
function __tryAgain() {
|
||||
__setDisabled(false);
|
||||
$("passwd-input").focus();
|
||||
$("passwd-input").select();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user