mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
added check if found domain is also configured
changed LOG_KEY variable
This commit is contained in:
parent
dc07313869
commit
3aa063d475
1 changed files with 17 additions and 11 deletions
|
|
@ -22,7 +22,7 @@ class LdapMailAccounts
|
||||||
/** @var Logger */
|
/** @var Logger */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
private const LOG_KEY = "Ldap";
|
private const LOG_KEY = "LDAP MAIL ACCOUNTS PLUGIN";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LdapMailAccount constructor.
|
* LdapMailAccount constructor.
|
||||||
|
|
@ -99,6 +99,7 @@ class LdapMailAccounts
|
||||||
}
|
}
|
||||||
|
|
||||||
//Basing on https://github.com/the-djmaze/snappymail/issues/616
|
//Basing on https://github.com/the-djmaze/snappymail/issues/616
|
||||||
|
|
||||||
$oActions = \RainLoop\Api::Actions();
|
$oActions = \RainLoop\Api::Actions();
|
||||||
|
|
||||||
//Check if SnappyMail is configured to allow additional accounts
|
//Check if SnappyMail is configured to allow additional accounts
|
||||||
|
|
@ -115,17 +116,22 @@ class LdapMailAccounts
|
||||||
|
|
||||||
$this->logger->Write("Domain: $sDomain Username: $sUsername Login: " . $oAccount->Login() . " E-Mail: " . $oAccount->Email(), \LOG_NOTICE, self::LOG_KEY);
|
$this->logger->Write("Domain: $sDomain Username: $sUsername Login: " . $oAccount->Login() . " E-Mail: " . $oAccount->Email(), \LOG_NOTICE, self::LOG_KEY);
|
||||||
|
|
||||||
//only execute if the found account isn't already in the list of additional accounts
|
//Check if the domain of the found mail address is in the list of configured domains
|
||||||
//and if the found account is different from the main account
|
if ($oActions->DomainProvider()->Load($sDomain, true))
|
||||||
//https://github.com/the-djmaze/snappymail/issues/705 should solve the missing logging if a domain is found in ldap
|
|
||||||
//but is not defined in the admin panel of SnappyMail
|
|
||||||
if (!$aAccounts["$sUsername@$sDomain"] && $oAccount->Email() !== "$sUsername@$sDomain")
|
|
||||||
{
|
{
|
||||||
//Try to login the user with the same password as the primary account has
|
//only execute if the found account isn't already in the list of additional accounts
|
||||||
//if this fails the user will see the new mail addresses but will be asked for the correct password
|
//and if the found account is different from the main account
|
||||||
$sPass = $oAccount->Password();
|
if (!$aAccounts["$sUsername@$sDomain"] && $oAccount->Email() !== "$sUsername@$sDomain")
|
||||||
$oNewAccount = RainLoop\Model\AdditionalAccount::NewInstanceFromCredentials($oActions, "$sUsername@$sDomain", $sUsername, $sPass);
|
{
|
||||||
$aAccounts["$sUsername@$sDomain"] = $oNewAccount->asTokenArray($oAccount);
|
//Try to login the user with the same password as the primary account has
|
||||||
|
//if this fails the user will see the new mail addresses but will be asked for the correct password
|
||||||
|
$sPass = $oAccount->Password();
|
||||||
|
$oNewAccount = RainLoop\Model\AdditionalAccount::NewInstanceFromCredentials($oActions, "$sUsername@$sDomain", $sUsername, $sPass);
|
||||||
|
$aAccounts["$sUsername@$sDomain"] = $oNewAccount->asTokenArray($oAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->logger->Write("Domain $sDomain is not part of configured domains in SnappyMail Admin Panel - mail address $sUsername@$sDomain will not be added.", \LOG_NOTICE, self::LOG_KEY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue