From f84d83e2702915ce845b4dd73bc3452739b36c4d Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Fri, 21 Aug 2020 01:21:38 +0300 Subject: [PATCH] Fixed pikvm/pikvm#48 --- web/share/js/login/main.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/share/js/login/main.js b/web/share/js/login/main.js index a76456d0..9bad70dd 100644 --- a/web/share/js/login/main.js +++ b/web/share/js/login/main.js @@ -58,7 +58,15 @@ function __login() { } else if (http.status === 403) { wm.error("Invalid username or password").then(__tryAgain); } else { - wm.error("Login error:
", http.responseText).then(__tryAgain); + let error = ""; + if (http.status === 400) { + try { error = JSON.parse(http.responseText)["result"]["error"]; } catch (_) { /* Nah */ } + } + if (error === "ValidatorError") { + wm.error("Incorrect username characters").then(__tryAgain); + } else { + wm.error("Login error:
", http.responseText).then(__tryAgain); + } } } }, body, "application/x-www-form-urlencoded");