I'm working on a hook for Api2::AddonDomain::addaddondomain to filter some domains while leaving their subdomains usable. I can block the event from happening so that it does not actually add the addon domain but cPanel is not displaying the status message to the enduser, instead it is reporting that the addon domain is adding successfully.
Here's my code:
Is there an issue with what I'm doing, or is displaying this message to the user something that is not supported by cPanel? It is present in the logs.
Here's my code:
Code:
#!/usr/bin/perl
package CheckDomain;
use strict;
use warnings;
use Cpanel::Logger;
use JSON;
my $logger = Cpanel::Logger->new();
my @blockedDomains = ( "example.com", "example.org" );
sub describe {
my $hooks = [
{
'category' => 'Cpanel',
'event' => 'Api2::AddonDomain::addaddondomain',
'stage' => 'pre',
'hook' => 'CheckDomain::checkdomain',
'exectype' => 'module',
'blocking' => 1,
}
];
return $hooks;
}
sub checkdomain {
my ( $context, @data ) = @_;
my $newdomain = $data[0]{'args'}{'newdomain'};
my $user = $data[0]{'user'};
foreach my $domain (@blockedDomains) {
if ($domain eq $newdomain) {
my $message = "ERROR: Registering domain $domain is not allowed. Try a subdomain of $domain such as $user.$newdomain";
my $status = 0;
return $status, $message;
}
}
return 1, "";
};
Is there an issue with what I'm doing, or is displaying this message to the user something that is not supported by cPanel? It is present in the logs.