Skip to content

Commit

Permalink
Contact ID improvements in CP
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga committed Mar 1, 2024
1 parent 9e5dd67 commit 6485162
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions cp/bootstrap/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,25 @@ function toArray($data){

function validate_identifier($identifier) {
if (!$identifier) {
return 'Please provide a contact ID';
return 'Oops! It looks like you forgot to provide a contact ID. Please make sure to include one.';
}

$length = strlen($identifier);

if ($length < 3) {
return 'Identifier type minLength value=3, maxLength value=16';
return 'The contact ID seems too short. It should be at least 3 characters long. Please try again.';
}

if ($length > 16) {
return 'Identifier type minLength value=3, maxLength value=16';
return 'The contact ID seems too long. It should be no more than 16 characters. Please try again.';
}

$pattern1 = '/^[A-Z]+\-[0-9]+$/';
$pattern2 = '/^[A-Za-z][A-Z0-9a-z]*$/';
$pattern3 = '/^[a-zA-Z0-9]{16}$/';

if (!preg_match($pattern1, $identifier) && !preg_match($pattern2, $identifier)) {
return 'The ID of the contact must contain letters (A-Z) (ASCII), hyphen (-), and digits (0-9).';
if (!preg_match($pattern1, $identifier) && !preg_match($pattern2, $identifier) && !preg_match($pattern3, $identifier)) {
return 'Your contact ID must contain letters (A-Z, a-z), digits (0-9), and optionally a hyphen (-). Please adjust and try again.';
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if [[ ("$OS" == "Ubuntu" && "$VER" == "22.04") || ("$OS" == "Debian GNU/Linux" &
else
echo "Installing required packages..."
apt update -y
apt install -y apt-transport-https ca-certificates curl debian-archive-keyring debian-keyring gnupg lsb-release software-properties-common ufw
apt install -y apt-transport-https ca-certificates cron curl debian-archive-keyring debian-keyring gnupg lsb-release software-properties-common ufw
curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' -o caddy-stable.gpg.key
Expand Down

0 comments on commit 6485162

Please sign in to comment.