Contact ID improvements in CP

This commit is contained in:
Pinga 2024-03-01 14:46:43 +02:00
parent 9e5dd67d5e
commit 6485162b14
2 changed files with 7 additions and 6 deletions

View file

@ -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.';
}
}

View file

@ -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