mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 23:47:03 +03:00
Check login handling for #969
This commit is contained in:
parent
90d039b36b
commit
99b73d87f6
4 changed files with 26 additions and 16 deletions
|
|
@ -49,24 +49,17 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
private bool $bIsLoggined = false;
|
private bool $bIsLoggined = false;
|
||||||
|
|
||||||
private string $sLogginedUser = '';
|
|
||||||
|
|
||||||
private bool $UTF8 = false;
|
private bool $UTF8 = false;
|
||||||
|
|
||||||
public function Hash() : string
|
public function Hash() : string
|
||||||
{
|
{
|
||||||
return \md5('ImapClientHash/'.
|
return \md5('ImapClientHash/'.
|
||||||
$this->GetLogginedUser() . '@' .
|
$this->Settings->Login . '@' .
|
||||||
$this->GetConnectedHost() . ':' .
|
$this->GetConnectedHost() . ':' .
|
||||||
$this->GetConnectedPort()
|
$this->GetConnectedPort()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetLogginedUser() : string
|
|
||||||
{
|
|
||||||
return $this->sLogginedUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \MailSo\RuntimeException
|
* @throws \MailSo\RuntimeException
|
||||||
|
|
@ -109,23 +102,26 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function Login(Settings $oSettings) : self
|
public function Login(Settings $oSettings) : self
|
||||||
{
|
{
|
||||||
|
if ($this->bIsLoggined) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($oSettings->ProxyAuthUser) && !empty($oSettings->ProxyAuthPassword)) {
|
if (!empty($oSettings->ProxyAuthUser) && !empty($oSettings->ProxyAuthPassword)) {
|
||||||
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($oSettings->ProxyAuthUser));
|
$sLogin = $oSettings->ProxyAuthUser;
|
||||||
$sPassword = $oSettings->ProxyAuthPassword;
|
$sPassword = $oSettings->ProxyAuthPassword;
|
||||||
$sProxyAuthUser = $oSettings->Login;
|
$sProxyAuthUser = $oSettings->Login;
|
||||||
} else {
|
} else {
|
||||||
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($oSettings->Login));
|
$sLogin = $oSettings->Login;
|
||||||
$sPassword = $oSettings->Password;
|
$sPassword = $oSettings->Password;
|
||||||
$sProxyAuthUser = '';
|
$sProxyAuthUser = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\strlen($sLogin) || !\strlen($sPassword))
|
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($sLogin));
|
||||||
{
|
|
||||||
|
if (!\strlen($sLogin) || !\strlen($sPassword)) {
|
||||||
$this->writeLogException(new \InvalidArgumentException, \LOG_ERR);
|
$this->writeLogException(new \InvalidArgumentException, \LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sLogginedUser = $sLogin;
|
|
||||||
|
|
||||||
$type = '';
|
$type = '';
|
||||||
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
foreach ($oSettings->SASLMechanisms as $sasl_type) {
|
||||||
if ($this->hasCapability("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) {
|
if ($this->hasCapability("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ abstract class NetClient
|
||||||
|
|
||||||
if ($this->IsConnected()) {
|
if ($this->IsConnected()) {
|
||||||
$this->writeLogException(new Exceptions\SocketAlreadyConnectedException, \LOG_ERR, false);
|
$this->writeLogException(new Exceptions\SocketAlreadyConnectedException, \LOG_ERR, false);
|
||||||
$this->Disconnect();
|
// $this->Disconnect();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Settings = $oSettings;
|
$this->Settings = $oSettings;
|
||||||
|
|
@ -202,6 +203,7 @@ abstract class NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// abstract public function Login(ConnectSettings $oSettings) : self;
|
||||||
abstract public function Logout() : void;
|
abstract public function Logout() : void;
|
||||||
|
|
||||||
public function IsConnected(bool $bThrowExceptionOnFalse = false) : bool
|
public function IsConnected(bool $bThrowExceptionOnFalse = false) : bool
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,10 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function Login(Settings $oSettings) : self
|
public function Login(Settings $oSettings) : self
|
||||||
{
|
{
|
||||||
|
if ($this->bIsLoggined) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$sLogin = $oSettings->Login;
|
$sLogin = $oSettings->Login;
|
||||||
$sPassword = $oSettings->Password;
|
$sPassword = $oSettings->Password;
|
||||||
$sLoginAuthKey = '';
|
$sLoginAuthKey = '';
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ use MailSo\Net\Enumerations\ConnectionSecurityType;
|
||||||
*/
|
*/
|
||||||
class SmtpClient extends \MailSo\Net\NetClient
|
class SmtpClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
|
private bool $bIsLoggined = false;
|
||||||
|
|
||||||
private string $sEhlo = '';
|
private string $sEhlo = '';
|
||||||
|
|
||||||
private bool $bRcpt = false;
|
private bool $bRcpt = false;
|
||||||
|
|
@ -103,11 +105,15 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
/**
|
/**
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \MailSo\RuntimeException
|
* @throws \MailSo\RuntimeException
|
||||||
* @throws \MailSo\Net\*
|
* @throws \MailSo\Net\Exceptions\*
|
||||||
* @throws \MailSo\Smtp\Exceptions\*
|
* @throws \MailSo\Smtp\Exceptions\*
|
||||||
*/
|
*/
|
||||||
public function Login(Settings $oSettings) : self
|
public function Login(Settings $oSettings) : self
|
||||||
{
|
{
|
||||||
|
if ($this->bIsLoggined) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($oSettings->Login));
|
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($oSettings->Login));
|
||||||
$sPassword = $oSettings->Password;
|
$sPassword = $oSettings->Password;
|
||||||
|
|
||||||
|
|
@ -183,6 +189,8 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->bIsLoggined = true;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue