Loading lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php +3 −4 Original line number Diff line number Diff line Loading @@ -13,12 +13,11 @@ class WeeklyBlacklistedDomainsJob extends TimedJob { private LoggerInterface $logger; private UserService $userService; private ITimeFactory $timeFactory; public const INTERVAL_PERIOD = 7 * 24 * 60 * 60;// Run for 7 days public function __construct(LoggerInterface $logger, ITimeFactory $timeFactory, UserService $userService) { parent::__construct($timeFactory); $this->setInterval(7 * 24 * 60 * 60); // Run for 7 days $this->setInterval(self::INTERVAL_PERIOD); $this->timeFactory = $timeFactory; $this->userService = $userService; $this->logger = $logger; Loading @@ -28,7 +27,7 @@ class WeeklyBlacklistedDomainsJob extends TimedJob { try { $this->userService->updateBlacklistedDomains(); } catch (\Exception $e) { $this->logger->error('Error running blacklisted domain migration', ['exception' => $e]); $this->logger->logException('Error updating blacklisted domains for account creation', ['exception' => $e]); return; } } Loading lib/Command/MigrateBlacklistedDomains.php +3 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ declare(strict_types=1); namespace OCA\EcloudAccounts\Command; use OCA\EcloudAccounts\AppInfo\Application; use OCA\EcloudAccounts\Service\UserService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; Loading @@ -18,12 +19,12 @@ class MigrateBlacklistedDomains extends Command { } protected function configure() { $this->setName('ecloud-accounts:migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); $this->setName(Application::APP_ID.':migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); } protected function execute(InputInterface $input, OutputInterface $output): int { $this->userService->updateBlacklistedDomains(); $output->writeln('Domains migrated successfully.'); $output->writeln('Updated blacklisted domains for creation.'); return 1; } } lib/Service/UserService.php +10 −4 Original line number Diff line number Diff line Loading @@ -285,12 +285,18 @@ class UserService { * @return bool True if the email domain is blacklisted, false otherwise. */ public function isBlacklistedEmail(string $email): bool { // Get the blacklisted domains from configuration $blacklistedDomainsInJson = $this->config->getAppValue(Application::APP_ID, 'blacklisted_domains'); $blacklistedDomains = json_decode($blacklistedDomainsInJson, true); $json_data = $this->config->getAppValue(Application::APP_ID, 'blacklisted_domains'); $blacklisted_domains = json_decode($json_data, true); // Split the email address into parts using explode $emailParts = explode('@', $email); $email_domain = strtolower(substr(strrchr($email, "@"), 1)); if (in_array($email_domain, $blacklisted_domains)) { // Extract the domain part $emailDomain = strtolower(end($emailParts)); // Check if the email domain is in the blacklisted domains array if (in_array($emailDomain, $blacklistedDomains)) { return true; // Email domain is blacklisted } return false; // Email domain is not blacklisted Loading Loading
lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php +3 −4 Original line number Diff line number Diff line Loading @@ -13,12 +13,11 @@ class WeeklyBlacklistedDomainsJob extends TimedJob { private LoggerInterface $logger; private UserService $userService; private ITimeFactory $timeFactory; public const INTERVAL_PERIOD = 7 * 24 * 60 * 60;// Run for 7 days public function __construct(LoggerInterface $logger, ITimeFactory $timeFactory, UserService $userService) { parent::__construct($timeFactory); $this->setInterval(7 * 24 * 60 * 60); // Run for 7 days $this->setInterval(self::INTERVAL_PERIOD); $this->timeFactory = $timeFactory; $this->userService = $userService; $this->logger = $logger; Loading @@ -28,7 +27,7 @@ class WeeklyBlacklistedDomainsJob extends TimedJob { try { $this->userService->updateBlacklistedDomains(); } catch (\Exception $e) { $this->logger->error('Error running blacklisted domain migration', ['exception' => $e]); $this->logger->logException('Error updating blacklisted domains for account creation', ['exception' => $e]); return; } } Loading
lib/Command/MigrateBlacklistedDomains.php +3 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ declare(strict_types=1); namespace OCA\EcloudAccounts\Command; use OCA\EcloudAccounts\AppInfo\Application; use OCA\EcloudAccounts\Service\UserService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; Loading @@ -18,12 +19,12 @@ class MigrateBlacklistedDomains extends Command { } protected function configure() { $this->setName('ecloud-accounts:migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); $this->setName(Application::APP_ID.':migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); } protected function execute(InputInterface $input, OutputInterface $output): int { $this->userService->updateBlacklistedDomains(); $output->writeln('Domains migrated successfully.'); $output->writeln('Updated blacklisted domains for creation.'); return 1; } }
lib/Service/UserService.php +10 −4 Original line number Diff line number Diff line Loading @@ -285,12 +285,18 @@ class UserService { * @return bool True if the email domain is blacklisted, false otherwise. */ public function isBlacklistedEmail(string $email): bool { // Get the blacklisted domains from configuration $blacklistedDomainsInJson = $this->config->getAppValue(Application::APP_ID, 'blacklisted_domains'); $blacklistedDomains = json_decode($blacklistedDomainsInJson, true); $json_data = $this->config->getAppValue(Application::APP_ID, 'blacklisted_domains'); $blacklisted_domains = json_decode($json_data, true); // Split the email address into parts using explode $emailParts = explode('@', $email); $email_domain = strtolower(substr(strrchr($email, "@"), 1)); if (in_array($email_domain, $blacklisted_domains)) { // Extract the domain part $emailDomain = strtolower(end($emailParts)); // Check if the email domain is in the blacklisted domains array if (in_array($emailDomain, $blacklistedDomains)) { return true; // Email domain is blacklisted } return false; // Email domain is not blacklisted Loading