WebUI: Fix reloading page after login

Manual backport of PR  #21832
Original author: Evgenii Ryshkov
See commit: 1e851b3637
This commit is contained in:
sledgehammer999 2024-12-08 12:12:44 +02:00
commit d156a44f8d
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2

View file

@ -37,11 +37,14 @@ function submitLoginForm(event) {
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.addEventListener("readystatechange", () => { xhr.addEventListener("readystatechange", () => {
if (xhr.readyState === 4) { // DONE state if (xhr.readyState === 4) { // DONE state
if ((xhr.status === 200) && (xhr.responseText === "Ok.")) if ((xhr.status === 200) && (xhr.responseText === "Ok.")) {
location.replace(location); location.replace(location);
else location.reload(true);
}
else {
errorMsgElement.textContent = "QBT_TR(Invalid Username or Password.)QBT_TR[CONTEXT=HttpServer]"; errorMsgElement.textContent = "QBT_TR(Invalid Username or Password.)QBT_TR[CONTEXT=HttpServer]";
} }
}
}); });
xhr.addEventListener("error", () => { xhr.addEventListener("error", () => {
errorMsgElement.textContent = (xhr.responseText !== "") errorMsgElement.textContent = (xhr.responseText !== "")