mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Add success feedback during login
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -40,13 +40,15 @@ function redirect() {
|
||||
window.location.replace(target);
|
||||
}
|
||||
|
||||
function wrongPassword(is_wrong) {
|
||||
if (is_wrong) {
|
||||
function wrongPassword(isError = false, isSuccess = false) {
|
||||
if (isError) {
|
||||
$("#pw-field").addClass("has-error");
|
||||
$("#error-label").show();
|
||||
$("#forgot-pw-box").removeClass("box-info").removeClass("collapsed-box").addClass("box-danger");
|
||||
$("#forgot-pw-box .box-body").show();
|
||||
$("#forgot-pw-toggle-icon").removeClass("fa-plus").addClass("fa-minus");
|
||||
} else if (isSuccess) {
|
||||
$("#pw-field").addClass("has-success");
|
||||
} else {
|
||||
$("#pw-field").removeClass("has-error");
|
||||
$("#error-label").hide();
|
||||
@@ -57,19 +59,20 @@ function wrongPassword(is_wrong) {
|
||||
}
|
||||
|
||||
function doLogin(response) {
|
||||
wrongPassword(false);
|
||||
wrongPassword(false, false);
|
||||
$.ajax({
|
||||
url: "/api/auth",
|
||||
method: "POST",
|
||||
data: JSON.stringify({ response: response, totp: parseInt($("#totp").val(), 10) }),
|
||||
})
|
||||
.done(function () {
|
||||
wrongPassword(false, true);
|
||||
redirect();
|
||||
})
|
||||
.fail(function (data) {
|
||||
if (data.status === 401) {
|
||||
// Login failed, show error message
|
||||
wrongPassword(true);
|
||||
wrongPassword(true, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,13 +175,19 @@ function delMsg(ids) {
|
||||
.done(function (response) {
|
||||
utils.enableAll();
|
||||
if (response === undefined) {
|
||||
utils.showAlert("success", "far fa-trash-alt", "Successfully deleted " + ids.length + " message" + (ids.length > 1 ? "s":""), "");
|
||||
utils.showAlert(
|
||||
"success",
|
||||
"far fa-trash-alt",
|
||||
"Successfully deleted " + ids.length + " message" + (ids.length > 1 ? "s" : ""),
|
||||
""
|
||||
);
|
||||
// Loop over id in case of multiple IDs
|
||||
for (var id in ids) {
|
||||
if (Object.hasOwnProperty.call(ids, id)) {
|
||||
table.row(id).remove();
|
||||
}
|
||||
}
|
||||
|
||||
table.draw(false).ajax.reload(null, false);
|
||||
} else {
|
||||
utils.showAlert("error", "", "Error while deleting message: " + ids, response.message);
|
||||
@@ -196,7 +202,7 @@ function delMsg(ids) {
|
||||
)
|
||||
.fail(function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while deleting message: " + id, jqXHR.responseText);
|
||||
utils.showAlert("error", "", "Error while deleting message: " + ids, jqXHR.responseText);
|
||||
console.log(exception); // eslint-disable-line no-console
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user