summaryrefslogtreecommitdiff
path: root/web/share/js
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-12-16 16:44:42 +0300
committerDevaev Maxim <[email protected]>2018-12-16 16:44:42 +0300
commitaa8d0aa01d1775b42b54e9f0779bccc583b25440 (patch)
tree30e23fb8c43384889f589ed742bb5fcc6d14a7c2 /web/share/js
parent0492ff2e02d0e2791e3fcea8ddabbb18dcab5b3b (diff)
fixed login error on empty username
Diffstat (limited to 'web/share/js')
-rw-r--r--web/share/js/login/main.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/web/share/js/login/main.js b/web/share/js/login/main.js
index 1362f821..378ece6c 100644
--- a/web/share/js/login/main.js
+++ b/web/share/js/login/main.js
@@ -18,21 +18,24 @@ function main() {
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);
+ if (user.length === 0) {
+ $("user-input").focus();
+ } else {
+ 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);
+ }
}
- }
- }, body, "application/x-www-form-urlencoded");
- __setDisabled(true);
+ }, body, "application/x-www-form-urlencoded");
+ __setDisabled(true);
+ }
}
function __setDisabled(disabled) {