Skip to content

Commit

Permalink
Add explicit confirmation when trying to replace existing password
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Jun 16, 2024
1 parent aab58a7 commit 513b700
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion scripts/pi-hole/js/settings-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var apiSessionsTable = null;
var ownSessionID = null;
var deleted = 0;
var TOTPdata = null;
var apppwSet = false;

function renderBool(data, type) {
// Display and search content
Expand Down Expand Up @@ -267,6 +268,7 @@ function processWebServerConfig() {
.done(function (data) {
setConfigValues("webserver", "webserver", data.config.webserver);
if (data.config.webserver.api.app_pwhash.value.length > 0) {
apppwSet = true;
$("#existing_apppw_warning").show();
$("#apppw_submit").text("Replace app password");
$("#apppw_submit").removeClass("btn-success");
Expand Down Expand Up @@ -333,7 +335,25 @@ $("#modal-apppw").on("shown.bs.modal", function () {

$("#apppw_submit").on("click", function () {
// Enable app password
setAppPassword();
if (!apppwSet) {
return setAppPassword();
}

// Else: Show confirm dialog
$.confirm({
text: "Are you sure you want to replace your previous app password? You will need to re-login to continue using the web interface.",
title: "Confirmation required",
confirm: setAppPassword,
cancel: function () {
// nothing to do
},
confirmButton: "Yes, replace password",
cancelButton: "No, go back",
post: true,
confirmButtonClass: "btn-danger",
cancelButtonClass: "btn-success",
dialogClass: "modal-dialog",
});
});

$("#apppw_clear").on("click", function () {
Expand Down

0 comments on commit 513b700

Please sign in to comment.