diff --git a/resources/lib/UnitySite.php b/resources/lib/UnitySite.php
index 2bedf8a6..78a4eace 100644
--- a/resources/lib/UnitySite.php
+++ b/resources/lib/UnitySite.php
@@ -56,4 +56,9 @@ public static function testValidSSHKey($key_str)
return false;
}
}
+
+ public function alert(string $msg): void
+ {
+ echo "";
+ }
}
diff --git a/webroot/panel/account.php b/webroot/panel/account.php
index c45602ca..59d2c282 100644
--- a/webroot/panel/account.php
+++ b/webroot/panel/account.php
@@ -6,9 +6,7 @@
require_once $LOC_HEADER;
-$invalid_ssh_dialogue = "";
+$invalid_ssh_dialogue = "Invalid SSH key. Please verify your public key file is valid.";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
switch ($_POST["form_type"]) {
@@ -21,7 +19,7 @@
if (UnitySite::testValidSSHKey($key)) {
array_push($added_keys, $key);
} else {
- echo $invalid_ssh_dialogue;
+ $SITE->alert($invalid_ssh_dialogue);
}
break;
case "import":
@@ -30,7 +28,7 @@
if (UnitySite::testValidSSHKey($key)) {
array_push($added_keys, $key);
} else {
- echo $invalid_ssh_dialogue;
+ $SITE->alert($invalid_ssh_dialogue);
}
break;
case "generate":
diff --git a/webroot/panel/groups.php b/webroot/panel/groups.php
index d1b2a013..a8c76d6e 100644
--- a/webroot/panel/groups.php
+++ b/webroot/panel/groups.php
@@ -9,11 +9,12 @@
$errors = array();
if (isset($_POST["form_name"])) {
+ $ok = true;
if (isset($_POST["pi"])) {
$pi_account = new UnityGroup(trim($_POST["pi"]), $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
if (!$pi_account->exists()) {
- // "\'" instead of "'", otherwise it will close a single quote used to place the message
- array_push($modalErrors, "This PI doesn\'t exist");
+ $SITE->alert("This PI doesn't exist");
+ $ok = false;
}
}
@@ -23,15 +24,17 @@
// existing PI request
if ($pi_account->requestExists($USER)) {
- array_push($modalErrors, "You\'ve already requested this");
+ $SITE->alert("You\'ve already requested this");
+ $ok = false;
}
if ($pi_account->userExists($USER)) {
- array_push($modalErrors, "You\'re already in this PI group");
+ $SITE->alert("You\'re already in this PI group");
+ $ok = false;
}
// Add row to sql
- if (empty($modalErrors)) {
+ if ($ok) {
$pi_account->newUserRequest($USER);
}
break;
@@ -145,19 +148,6 @@
openModal("Add New PI", "/panel/modal/new_pi.php");
});
- 0) {
- $errorHTML = "";
- foreach ($modalErrors as $error) {
- $errorHTML .= "$error";
- }
-
- echo "openModal('Add New PI', '" .
- $CONFIG["site"]["prefix"] . "/panel/modal/new_pi.php', '" . $errorHTML . "');";
- }
- ?>
-
var ajax_url = "/panel/ajax/get_group_members.php?pi_uid=";