diff --git a/list.php b/list.php index c0a0cf52..8087f20f 100644 --- a/list.php +++ b/list.php @@ -47,14 +47,17 @@ function getFullName() { @@ -115,8 +118,10 @@ require "footer.php"; $.ajax({ url: "php/add.php", method: "get", - data: {"domain":domain, "list":""}, + data: {"domain":domain, "list":"", "pass":password}, success: function(response) { + if(response.length !== 0) + return; document.getElementById("alSuccess").hidden = false; refresh(); }, @@ -133,8 +138,10 @@ require "footer.php"; $.ajax({ url: "php/sub.php", method: "get", - data: {"domain":entry, "list":""}, + data: {"domain":entry, "list":"", "pass":password}, success: function(response) { + if(response.length !== 0) + return; document.getElementById("list").removeChild(document.getElementById(index)); }, error: function(jqXHR, exception) { @@ -145,24 +152,61 @@ require "footer.php"; } function getPassword(callback) { - // Return if we already have the password + // Check password and return if(password.length !== 0) { - callback(); + $.ajax({ + url: "php/checkPass.php", + method: "get", + data: {"pass":password}, + success: function(response) { + if(response === "Correct") + callback(); + }, + error: function(jqXHR, exception) { + alert("Failed to check password!"); + } + }); return; } // Prompt the user for password - $("#passModal").modal(); + var modal = $("#passModal"); + modal.modal(); // Handle enter button $("#passBtn").on("click", function() { var passInput = $("#passInput"); + var passAlert = $("#alPassword"); password = passInput.val(); - passInput.html(""); - // Execute callback if password was entered - if(password.length !== 0) - callback(); + // Execute callback if entered + if(password.length !== 0) { + // Check if password is correct + $.ajax({ + url: "php/checkPass.php", + method: "get", + data: {"pass":password}, + success: function(response) { + if(response === "Correct") { + passInput.html(""); + passAlert.hide(); + modal.modal("hide"); + callback(); + } + else { + passAlert.show(); + password = ""; + } + }, + error: function(jqXHR, exception) { + alert("Failed to check password!"); + password = ""; + } + }); + } + else { + passAlert.show() + } }); } diff --git a/php/add.php b/php/add.php index 95585ee7..c602119d 100644 --- a/php/add.php +++ b/php/add.php @@ -1,7 +1,12 @@