Cleanup MailSo Validator

Cleanup removed features
This commit is contained in:
djmaze 2020-03-20 14:53:12 +01:00
parent 8fe8369b2a
commit 1009398d0c
15 changed files with 65 additions and 192 deletions

View file

@ -27,7 +27,7 @@ if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
{
if (0 === \strpos($sClassName, $sNamespaceName.'\\'))
{
include RAINLOOP_APP_LIBRARIES_PATH.$sPrefix.\strtr($sClassName, '\\', '/').'.php';
include RAINLOOP_APP_LIBRARIES_PATH.\strtr($sClassName, '\\', '/').'.php';
break;
}
}

View file

@ -87,7 +87,7 @@ class Crypt
private static function XxteaDecrypt(string $sEncryptedString, string $sKey) : string
{
if (\is_callable('xxtea_decrypt')) {
return xxtea_decrypt($sString, $sKey);
return xxtea_decrypt($sEncryptedString, $sKey);
}
$aV = self::str2long($sEncryptedString, false);
@ -166,6 +166,6 @@ class Crypt
private static function int32(int $iN) : int
{
return ($n & 0xffffffff);
return $iN & 0xffffffff;
}
}

View file

@ -17,51 +17,13 @@ namespace MailSo\Base;
*/
class Validator
{
public static function EmailString(string $sEmail, array $aAllowedInternalDomains = array('localhost')) : bool
{
$bResult = false;
if (\MailSo\Base\Validator::NotEmptyString($sEmail, true))
{
$bResult = false !== \filter_var($sEmail, FILTER_VALIDATE_EMAIL);
if (!$bResult)
{
$aSplit = \explode("@", $sEmail);
$bResult = 2 === \count($aSplit) &&
\in_array($aSplit[1], $aAllowedInternalDomains) &&
false !== \filter_var(($aSplit[0].'@example.com'), FILTER_VALIDATE_EMAIL);
}
}
return $bResult;
}
public static function SimpleEmailString(string $sEmail) : bool
{
return \MailSo\Base\Validator::NotEmptyString($sEmail, true) &&
!!\preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\.\+\-_]*@[a-zA-Z0-9][a-zA-Z0-9\.\+\-_]*$/', $sEmail);
}
public static function NotEmptyString(string $sString, bool $bTrim = false) : bool
{
return \is_string($sString) &&
(0 < \strlen($bTrim ? \trim($sString) : $sString));
}
public static function NotEmptyArray(array $aList) : bool
{
return \is_array($aList) && 0 < \count($aList);
}
public static function RangeInt(int $iNumber, int $iMin = null, int $iMax = null) : bool
{
return \is_int($iNumber) &&
(null !== $iMin && $iNumber >= $iMin || null === $iMin) &&
(null !== $iMax && $iNumber <= $iMax || null === $iMax);
return (null === $iMin || $iNumber >= $iMin) && (null === $iMax || $iNumber <= $iMax);
}
public static function PortInt(int $iPort) : bool
{
return \MailSo\Base\Validator::RangeInt($iPort, 0, 65535);
return static::RangeInt($iPort, 0, 65535);
}
}

View file

@ -21,11 +21,11 @@ class Hooks
*/
static $aCallbacks = array();
static public function Run(string $sName, array $aArg = array())
static public function Run(string $sName, array $aArg = array()) : void
{
if (isset(\MailSo\Hooks::$aCallbacks[$sName]))
if (isset(static::$aCallbacks[$sName]))
{
foreach (\MailSo\Hooks::$aCallbacks[$sName] as $mCallback)
foreach (static::$aCallbacks[$sName] as $mCallback)
{
\call_user_func_array($mCallback, $aArg);
}
@ -35,16 +35,16 @@ class Hooks
/**
* @param mixed $mCallback
*/
static public function Add(string $sName, $mCallback)
static public function Add(string $sName, $mCallback) : void
{
if (\is_callable($mCallback))
{
if (!isset(\MailSo\Hooks::$aCallbacks[$sName]))
if (!isset(static::$aCallbacks[$sName]))
{
\MailSo\Hooks::$aCallbacks[$sName] = array();
static::$aCallbacks[$sName] = array();
}
\MailSo\Hooks::$aCallbacks[$sName][] = $mCallback;
static::$aCallbacks[$sName][] = $mCallback;
}
}
}

View file

@ -172,8 +172,7 @@ class ImapClient extends \MailSo\Net\NetClient
public function Login(string $sLogin, string $sPassword, string $sProxyAuthUser = '',
bool $bUseAuthPlainIfSupported = true, bool $bUseAuthCramMd5IfSupported = true) : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) ||
!\MailSo\Base\Validator::NotEmptyString($sPassword, true))
if (!strlen(\trim($sLogin)) || !strlen(\trim($sPassword)))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException(),
@ -341,7 +340,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public function IsSupported(string $sExtentionName) : bool
{
$bResult = \MailSo\Base\Validator::NotEmptyString($sExtentionName, true);
$bResult = strlen(\trim($sExtentionName));
if ($bResult && null === $this->aCapabilityItems)
{
$this->aCapabilityItems = $this->Capability();
@ -762,7 +761,7 @@ class ImapClient extends \MailSo\Net\NetClient
}
}
if (!\MailSo\Base\Validator::NotEmptyString($sFolderName, true))
if (!strlen(\trim($sFolderName)))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
@ -821,7 +820,7 @@ class ImapClient extends \MailSo\Net\NetClient
public function Fetch(array $aInputFetchItems, string $sIndexRange, bool $bIndexIsUid) : array
{
$sIndexRange = (string) $sIndexRange;
if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true))
if (!strlen(\trim($sIndexRange)))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException(),
@ -928,7 +927,7 @@ class ImapClient extends \MailSo\Net\NetClient
public function MessageSimpleSort(array $aSortTypes, string $sSearchCriterias = 'ALL', bool $bReturnUid = true) : array
{
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias
$sSearchCriterias = !strlen(\trim($sSearchCriterias)) || '*' === $sSearchCriterias
? 'ALL' : $sSearchCriterias;
if (!\is_array($aSortTypes) || 0 === \count($aSortTypes))
@ -1252,7 +1251,7 @@ class ImapClient extends \MailSo\Net\NetClient
public function MessageSimpleThread(string $sSearchCriterias = 'ALL', bool $bReturnUid = true, string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8) : array
{
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias
$sSearchCriterias = !strlen(\trim($sSearchCriterias)) || '*' === $sSearchCriterias
? 'ALL' : $sSearchCriterias;
$sThreadType = '';
@ -1390,8 +1389,8 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public function MessageStoreFlag(string $sIndexRange, bool $bIndexIsUid, array $aInputStoreItems, string $sStoreAction) : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true) ||
!\MailSo\Base\Validator::NotEmptyString($sStoreAction, true) ||
if (!strlen(\trim($sIndexRange)) ||
!strlen(\trim($sStoreAction)) ||
0 === \count($aInputStoreItems))
{
return false;
@ -1462,7 +1461,8 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public function SendRequest(string $sCommand, array $aParams = array(), bool $bBreakOnLiteral = false) : string
{
if (!\MailSo\Base\Validator::NotEmptyString($sCommand, true) || !\is_array($aParams))
$sCommand = \trim($sCommand);
if (!\strlen($sCommand))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException(),
@ -1473,14 +1473,11 @@ class ImapClient extends \MailSo\Net\NetClient
$sTag = $this->getNewTag();
$sCommand = \trim($sCommand);
$sRealCommand = $sTag.' '.$sCommand.$this->prepearParamLine($aParams);
$sRealCommand = $sTag.' '.$sCommand.$this->prepareParamLine($aParams);
$sFakeCommand = '';
$aFakeParams = $this->secureRequestParams($sCommand, $aParams);
if (null !== $aFakeParams)
{
$sFakeCommand = $sTag.' '.$sCommand.$this->prepearParamLine($aFakeParams);
if ($aFakeParams = $this->secureRequestParams($sCommand, $aParams)) {
$sFakeCommand = $sTag.' '.$sCommand.$this->prepareParamLine($aFakeParams);
}
$this->aTagTimeouts[$sTag] = \microtime(true);
@ -1505,19 +1502,11 @@ class ImapClient extends \MailSo\Net\NetClient
private function secureRequestParams(string $sCommand, array $aParams) : ?array
{
$aResult = null;
switch ($sCommand)
{
case 'LOGIN':
$aResult = $aParams;
if (\is_array($aResult) && 2 === count($aResult))
{
$aResult[1] = '"********"';
}
break;
if ('LOGIN' === $sCommand && isset($aParams[1])) {
$aParams[1] = '"********"';
return $aParams;
}
return $aResult;
return null;
}
/**
@ -2241,7 +2230,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $bResult;
}
private function prepearParamLine(array $aParams = array()) : string
private function prepareParamLine(array $aParams = array()) : string
{
$sReturn = '';
if (\is_array($aParams) && 0 < \count($aParams))
@ -2250,7 +2239,7 @@ class ImapClient extends \MailSo\Net\NetClient
{
if (\is_array($mParamItem) && 0 < \count($mParamItem))
{
$sReturn .= ' ('.\trim($this->prepearParamLine($mParamItem)).')';
$sReturn .= ' ('.\trim($this->prepareParamLine($mParamItem)).')';
}
else if (\is_string($mParamItem))
{

View file

@ -175,7 +175,7 @@ abstract class Driver
{
return \ltrim(
($this->bTimePrefix ? '['.$sTimePrefix.']' : '').
($this->bGuidPrefix ? '['.\MailSo\Log\Logger::Guid().']' : '').
($this->bGuidPrefix ? '['.Logger::Guid().']' : '').
($this->bTypedPrefix ? ' '.$this->getTypedPrefix($iType, $sName) : '')
).$sDesc;
}
@ -188,7 +188,7 @@ abstract class Driver
protected function getTimeWithMicroSec() : string
{
$aMicroTimeItems = \explode(' ', \microtime());
return \MailSo\Log\Logger::DateHelper($this->sDatePattern, $this->sTimeOffset, $aMicroTimeItems[1]).'.'.
return Logger::DateHelper($this->sDatePattern, $this->sTimeOffset, $aMicroTimeItems[1]).'.'.
\str_pad((int) ($aMicroTimeItems[0] * 1000), 3, '0', STR_PAD_LEFT);
}

View file

@ -270,7 +270,7 @@ class MailClient
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Message(string $sFolderName, int $iIndex, bool $bIndexIsUid = true, ?\MailSo\Cache\CacheClient $oCacher = null, int $iBodyTextLimit = 0) : ?\MailSo\Mail\Message
public function Message(string $sFolderName, int $iIndex, bool $bIndexIsUid = true, ?\MailSo\Cache\CacheClient $oCacher = null, int $iBodyTextLimit = 0) : ?Message
{
if (!\MailSo\Base\Validator::RangeInt($iIndex, 1))
{
@ -346,7 +346,7 @@ class MailClient
$aFetchResponse = $this->oImapClient->Fetch($aFetchItems, $iIndex, $bIndexIsUid);
if (0 < \count($aFetchResponse))
{
$oMessage = \MailSo\Mail\Message::NewFetchResponseInstance(
$oMessage = Message::NewFetchResponseInstance(
$sFolderName, $aFetchResponse[0], $oBodyStructure);
}
@ -1482,7 +1482,7 @@ class MailClient
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageListByRequestIndexOrUids(\MailSo\Mail\MessageCollection $oMessageCollection, array $aRequestIndexOrUids, bool $bIndexAsUid, bool $bSimple = false)
public function MessageListByRequestIndexOrUids(MessageCollection $oMessageCollection, array $aRequestIndexOrUids, bool $bIndexAsUid, bool $bSimple = false)
{
if (\is_array($aRequestIndexOrUids) && 0 < \count($aRequestIndexOrUids))
{
@ -1617,7 +1617,7 @@ class MailClient
public function MessageList(string $sFolderName, int $iOffset = 0, int $iLimit = 10,
string $sSearch = '', string $sPrevUidNext = '', ?\MailSo\Cache\CacheClient $oCacher = null,
bool $bUseSortIfSupported = false, bool $bUseThreadSortIfSupported = false,
string $sThreadUid = '', string $sFilter = '')
string $sThreadUid = '', string $sFilter = '') : MessageCollection
{
$sFilter = \trim($sFilter);
$sSearch = \trim($sSearch);
@ -1905,7 +1905,7 @@ class MailClient
$iCountLimit = $iForeachLimit;
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder \MailSo\Mail\Folder */ $oFolder)
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder Folder */ $oFolder)
{
// mandatory folders
if ($oFolder && \in_array(\str_replace(' ', '', \strtolower($oFolder->NameRaw())), $aFilteredNames))
@ -1915,7 +1915,7 @@ class MailClient
}
}
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder \MailSo\Mail\Folder */ $oFolder)
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder Folder */ $oFolder)
{
// subscribed folders
if ($oFolder && $oFolder->IsSubscribed())
@ -1943,7 +1943,7 @@ class MailClient
if ($iOptimizationLimit >= \count($aNewMailFoldersHelper))
{
// name filter
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder \MailSo\Mail\Folder */ $oFolder)
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder Folder */ $oFolder)
{
if ($oFolder && !\preg_match('/[{}\[\]]/', $oFolder->NameRaw()))
{
@ -1971,7 +1971,7 @@ class MailClient
if ($iOptimizationLimit >= \count($aNewMailFoldersHelper))
{
// other
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder \MailSo\Mail\Folder */ $oFolder)
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder Folder */ $oFolder)
{
if ($oFolder)
{
@ -2006,7 +2006,7 @@ class MailClient
return $aMailFoldersHelper;
}
public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : \MailSo\Mail\FolderCollection
public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : FolderCollection
{
$oFolderCollection = false;
@ -2101,8 +2101,7 @@ class MailClient
*/
public function FolderCreate(string $sFolderNameInUtf8, string $sFolderParentFullNameRaw = '', bool $bSubscribeOnCreation = true, string $sDelimiter = '') : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sFolderNameInUtf8, true) ||
!\is_string($sFolderParentFullNameRaw))
if (!strlen(\trim($sFolderNameInUtf8)))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}

View file

@ -42,7 +42,7 @@ class Email
*/
private function __construct(string $sEmail, string $sDisplayName = '')
{
if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true))
if (!strlen(\trim($sEmail)))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
@ -70,7 +70,7 @@ class Email
public static function Parse(string $sEmailAddress) : self
{
$sEmailAddress = \MailSo\Base\Utils::Trim($sEmailAddress);
if (!\MailSo\Base\Validator::NotEmptyString($sEmailAddress, true))
if (!strlen(\trim($sEmailAddress)))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}

View file

@ -48,7 +48,7 @@ class EmailDep
*/
private function __construct(string $sEmail, string $sDisplayName = '', string $sRemark = '')
{
if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true))
if (!strlen(\trim($sEmail)))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
@ -77,7 +77,7 @@ class EmailDep
public static function Parse(string $sEmailAddress) : \MailSo\Mime\Email
{
$sEmailAddress = \MailSo\Base\Utils::Trim($sEmailAddress);
if (!\MailSo\Base\Validator::NotEmptyString($sEmailAddress, true))
if (!strlen(\trim($sEmailAddress)))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}

View file

@ -171,7 +171,7 @@ abstract class NetClient
bool $bVerifySsl = false, bool $bAllowSelfSigned = true,
string $sClientCert = '') : void
{
if (!\MailSo\Base\Validator::NotEmptyString($sServerName, true) || !\MailSo\Base\Validator::PortInt($iPort))
if (!strlen(\trim($sServerName)) || !\MailSo\Base\Validator::PortInt($iPort))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException(),

View file

@ -116,8 +116,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
*/
public function Login(string $sLogin, string $sPassword, string $sLoginAuthKey = '') : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) ||
!\MailSo\Base\Validator::NotEmptyString($sPassword, true))
if (!strlen(\trim($sLogin)) || !strlen(\trim($sPassword)))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException(),
@ -434,7 +433,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
*/
private function sendRequest(string $sRequest) : void
{
if (!\MailSo\Base\Validator::NotEmptyString($sRequest, true))
if (!strlen(\trim($sRequest)))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException(),

View file

@ -357,7 +357,7 @@ class SmtpClient extends \MailSo\Net\NetClient
*/
public function Data(string $sData) : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sData, true))
if (!strlen(\trim($sData)))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
@ -525,7 +525,7 @@ class SmtpClient extends \MailSo\Net\NetClient
*/
private function sendRequest(string $sCommand, string $sAddToCommand = '', bool $bSecureLog = false) : void
{
if (!\MailSo\Base\Validator::NotEmptyString($sCommand, true))
if (!strlen(\trim($sCommand)))
{
$this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException(),

View file

@ -1053,14 +1053,14 @@ class Actions
if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword))
{
$oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
if ($oDomain instanceof \RainLoop\Model\Domain)
if ($oDomain)
{
if ($oDomain->ValidateWhiteList($sEmail, $sLogin))
{
$oAccount = \RainLoop\Model\Account::NewInstance($sEmail, $sLogin, $sPassword, $oDomain, $sSignMeToken, '', '', $sClientCert);
$this->Plugins()->RunHook('filter.acount', array($oAccount));
if ($bThrowProvideException && !($oAccount instanceof \RainLoop\Model\Account))
if ($bThrowProvideException && !$oAccount)
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
}
@ -1098,7 +1098,7 @@ class Actions
$oAccount = $this->LoginProvide($aAccountHash[1], $aAccountHash[2], $aAccountHash[3],
empty($aAccountHash[5]) ? '' : $aAccountHash[5], empty($aAccountHash[11]) ? '' : $aAccountHash[11], $bThrowExceptionOnFalse);
if ($oAccount instanceof \RainLoop\Model\Account)
if ($oAccount)
{
if (!empty($aAccountHash[8]) && !empty($aAccountHash[9])) // init proxy user/password
{
@ -1119,7 +1119,7 @@ class Actions
}
}
if ($bThrowExceptionOnFalse && !($oResult instanceof \RainLoop\Model\Account))
if ($bThrowExceptionOnFalse && !$oResult)
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
}
@ -1207,7 +1207,6 @@ class Actions
'materialDesign' => (bool) $oConfig->Get('labs', 'use_material_design', true),
'folderSpecLimit' => (int) $oConfig->Get('labs', 'folders_spec_limit', 50),
'faviconStatus' => (bool) $oConfig->Get('labs', 'favicon_status', true),
'allowCmdInterface' => (bool) $oConfig->Get('labs', 'allow_cmd', false),
'listPermanentFiltered' => '' !== \trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', '')),
'themes' => $this->GetThemes($bMobile, false),
'languages' => $this->GetLanguages(false),
@ -1388,8 +1387,6 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
else
{
$oAccount = null;
$aResult['IncludeBackground'] = $aResult['LoginBackground'];
$aResult['IncludeCss'] = $aResult['LoginCss'];
@ -1496,7 +1493,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$aResult['UserBackgroundName'] = '';
$aResult['UserBackgroundHash'] = '';
if (!$bAdmin && $oAccount instanceof \RainLoop\Model\Account)
if (!$bAdmin && $oAccount)
{
$aResult['ParentEmail'] = $oAccount->ParentEmail();
@ -1799,7 +1796,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$sLine = \trim(\implode('.', $aDomainParts), '. ');
$oDomain = $oDomainProvider->Load($sLine, false);
if ($oDomain && $oDomain instanceof \RainLoop\Model\Domain)
if ($oDomain)
{
$bAdded = true;
$this->Logger()->Write('Check "'.$sLine.'": OK ('.$sEmail.' > '.$sEmail.'@'.$sLine.')',
@ -1821,7 +1818,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
{
$sLine = $sUserHost;
$oDomain = $oDomainProvider->Load($sLine, true);
if ($oDomain && $oDomain instanceof \RainLoop\Model\Domain)
if ($oDomain && $oDomain)
{
$bAdded = true;
$this->Logger()->Write('Check "'.$sLine.'" with wildcard: OK ('.$sEmail.' > '.$sEmail.'@'.$sLine.')',
@ -1880,17 +1877,12 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
{
$oAccount = $this->LoginProvide($sEmail, $sLogin, $sPassword, $sSignMeToken, $sClientCert, true);
if (!($oAccount instanceof \RainLoop\Model\Account))
if (!$oAccount)
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
}
$this->Plugins()->RunHook('event.login-post-login-provide', array($oAccount));
if (!($oAccount instanceof \RainLoop\Model\Account))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
}
}
catch (\Throwable $oException)
{
@ -3372,7 +3364,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this);
return $this->DefaultResponse(__FUNCTION__,
$oDomain instanceof \RainLoop\Model\Domain ? $this->DomainProvider()->Save($oDomain) : false);
$oDomain ? $this->DomainProvider()->Save($oDomain) : false);
}
public function DoAdminDomainAliasSave() : array
@ -4043,7 +4035,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
if (!$bDisable)
{
$oPlugin = $this->Plugins()->CreatePluginByName($sName);
if ($oPlugin && ($oPlugin instanceof \RainLoop\Plugins\AbstractPlugin))
if ($oPlugin)
{
$sValue = $oPlugin->Supported();
if (0 < \strlen($sValue))
@ -4921,7 +4913,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList, $oException);
}
if ($oMessageList instanceof \MailSo\Mail\MessageCollection)
if ($oMessageList)
{
$this->cacheByKey($sRawKey);
}
@ -6276,7 +6268,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessage, $oException);
}
if ($oMessage instanceof \MailSo\Mail\Message)
if ($oMessage)
{
$this->Plugins()
->RunHook('filter.result-message', array($oMessage))
@ -8168,7 +8160,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$sLanguage = $this->Config()->Get('webmail', 'language', 'en');
if ($oAccount instanceof \RainLoop\Model\Account)
if ($oAccount)
{
$oSettings = $this->SettingsProvider()->Load($oAccount);
if ($oSettings instanceof \RainLoop\Settings)

View file

@ -333,7 +333,6 @@ Enables caching in the system'),
'Experimental settings. Handle with care.
'),
'ignore_folders_subscription' => array(false),
'check_new_password_strength' => array(true),
'update_channel' => array('stable'),
'allow_prefetch' => array(true),
'allow_smart_html_links' => array(true),
@ -347,7 +346,6 @@ Enables caching in the system'),
'allow_html_editor_biti_buttons' => array(false),
'allow_ctrl_enter_on_compose' => array(true),
'try_to_detect_hidden_images' => array(false),
'hide_dangerous_actions' => array(false),
'use_app_debug_js' => array(false),
'use_mobile_version_for_tablets' => array(false),
'use_app_debug_css' => array(false),
@ -391,9 +389,6 @@ Enables caching in the system'),
'force_https' => array(false),
'custom_login_link' => array(''),
'custom_logout_link' => array(''),
'allow_external_login' => array(false),
'allow_external_sso' => array(false),
'external_sso_key' => array(''),
'http_client_ip_check_proxy' => array(false),
'fast_cache_memcache_host' => array('127.0.0.1'),
'fast_cache_memcache_port' => array(11211),
@ -407,7 +402,6 @@ Enables caching in the system'),
'replace_env_in_configuration' => array(''),
'startup_url' => array(''),
'strict_html_parser' => array(false),
'allow_cmd' => array(false),
'dev_email' => array(''),
'dev_password' => array('')
),

View file

@ -884,28 +884,6 @@ class ServiceActions
$oAccount = null;
$bLogout = true;
if ($this->oActions->Config()->Get('labs', 'allow_external_login', false))
{
$sEmail = \trim($this->oHttp->GetRequest('Email', ''));
$sPassword = $this->oHttp->GetRequest('Password', '');
try
{
$oAccount = $this->oActions->LoginProcess($sEmail, $sPassword);
$this->oActions->AuthToken($oAccount);
$bLogout = !($oAccount instanceof \RainLoop\Model\Account);
}
catch (\Throwable $oException)
{
$this->oActions->Logger()->WriteException($oException);
}
if ($bLogout)
{
$this->oActions->SetAuthLogoutToken();
}
}
switch (\strtolower($this->oHttp->GetRequest('Output', 'Redirect')))
{
case 'json':
@ -941,46 +919,6 @@ class ServiceActions
return '';
}
public function ServiceExternalSso() : string
{
$this->oHttp->ServerNoCache();
$sResult = '';
$bLogout = true;
$sKey = $this->oActions->Config()->Get('labs', 'external_sso_key', '');
if ($this->oActions->Config()->Get('labs', 'allow_external_sso', false) &&
!empty($sKey) && $sKey === \trim($this->oHttp->GetRequest('SsoKey', '')))
{
$sEmail = \trim($this->oHttp->GetRequest('Email', ''));
$sPassword = $this->oHttp->GetRequest('Password', '');
$sResult = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword);
$bLogout = 0 === \strlen($sResult);
switch (\strtolower($this->oHttp->GetRequest('Output', 'Plain')))
{
case 'plain':
@\header('Content-Type: text/plain');
break;
case 'json':
@\header('Content-Type: application/json; charset=utf-8');
$sResult = \MailSo\Base\Utils::Php2js(array(
'Action' => 'ExternalSso',
'Result' => $sResult
), $this->Logger());
break;
}
}
if ($bLogout)
{
$this->oActions->SetAuthLogoutToken();
}
return $sResult;
}
private function changeAction()
{
$this->oHttp->ServerNoCache();