Added the proper logging for #1706

This commit is contained in:
the-djmaze 2024-10-08 13:06:43 +02:00
parent ba85eda7f0
commit 28a8e3c157
6 changed files with 21 additions and 24 deletions

View file

@ -69,6 +69,7 @@ trait Accounts
}
/**
* Add/Edit additional account
* @throws \MailSo\RuntimeException
*/
public function DoAccountSetup(): array

View file

@ -207,6 +207,7 @@ trait UserAuth
// Test the login
$oImapClient = new \MailSo\Imap\ImapClient;
$oImapClient->SetLogger($this->Logger());
$this->imapConnect($oAccount, false, $oImapClient);
}
$this->SetAdditionalAuthToken($oAccount);

View file

@ -165,7 +165,8 @@ abstract class Account implements \JsonSerializable
// $aAccountHash['login'] = $oDomain->ImapSettings()->fixUsername($aAccountHash['login']);
$oAccount = new static;
$oAccount->sEmail = \SnappyMail\IDN::emailToAscii($aAccountHash['email']);
$oAccount->sImapUser = \SnappyMail\IDN::emailToAscii($aAccountHash['login']);
// $oAccount->sImapUser = \SnappyMail\IDN::emailToAscii($aAccountHash['login']);
$oAccount->sImapUser = $aAccountHash['login'];
$oAccount->setImapPass(new SensitiveString($aAccountHash['pass']));
$oAccount->oDomain = $oDomain;
$oActions->Plugins()->RunHook('filter.account', array($oAccount));
@ -286,7 +287,7 @@ abstract class Account implements \JsonSerializable
*/
/**
* @deprecated
* @deprecated since v2.36.1
*/
public function IncLogin() : string
{

View file

@ -106,7 +106,7 @@ class Domain implements \JsonSerializable
public function ValidateWhiteList(string $sEmail) : bool
{
$sW = \trim($this->whiteList);
$sW = $this->whiteList;
if (!$sW) {
return true;
}
@ -210,7 +210,7 @@ class Domain implements \JsonSerializable
$oDomain->SMTP->setSender = !empty($aDomain['smtp_set_sender']);
$oDomain->SMTP->usePhpMail = !empty($aDomain['smtp_php_mail']);
$oDomain->whiteList = \trim($aDomain['white_list'] ?? '');
$oDomain->whiteList = $aDomain['white_list'] ?? '';
$oDomain->Normalize();
}

View file

@ -6,15 +6,9 @@ use RainLoop\Exceptions\ClientException;
class Domain extends AbstractProvider
{
/**
* @var Domain\DomainInterface
*/
private $oDriver;
private Domain\DomainInterface $oDriver;
/**
* @var \RainLoop\Plugins\Manager
*/
private $oPlugins;
private \RainLoop\Plugins\Manager $oPlugins;
public function __construct(Domain\DomainInterface $oDriver, \RainLoop\Plugins\Manager $oPlugins)
{
@ -86,10 +80,13 @@ class Domain extends AbstractProvider
{
$oDomain = $this->Load(\MailSo\Base\Utils::getEmailAddressDomain($sEmail), true);
if (!$oDomain) {
$this->logWrite("{$sEmail} has no domain configuration", \LOG_INFO, 'domain');
throw new ClientException(Notifications::DomainNotAllowed);
}
if (!$oDomain->ValidateWhiteList($sEmail)) {
$this->logWrite("{$sEmail} not whitelisted in {$oDomain->Name()}", \LOG_WARNING, 'domain');
throw new ClientException(Notifications::AccountNotAllowed);
// throw new ClientException(Notifications::AccountNotAllowed, null, "{$sEmail} not whitelisted in {$oDomain->Name()}");
}
return $oDomain;
}