This commit is contained in:
the-djmaze 2023-02-15 23:04:23 +01:00
parent 8c97b64a55
commit 38c4b4e26e
4 changed files with 23 additions and 19 deletions

View file

@ -73,11 +73,18 @@ class SnappyMailHelper
}
*/
if ($doLogin && $aCredentials[1] && $aCredentials[2]) {
$oActions->Logger()->AddSecret($aCredentials[2]);
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2], false);
if ($oAccount) {
$oActions->Plugins()->RunHook('login.success', array($oAccount));
$oActions->SetAuthToken($oAccount);
try {
$oActions->Logger()->AddSecret($aCredentials[2]);
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2], false);
if ($oAccount) {
$oActions->Plugins()->RunHook('login.success', array($oAccount));
$oActions->SetAuthToken($oAccount);
}
} catch (\Throwable $e) {
// Login failure, reset password to prevent more attempts
$sUID = \OC::$server->getUserSession()->getUser()->getUID();
\OC::$server->getSession()['snappymail-password'] = '';
\OC::$server->getConfig()->setUserValue($sUID, 'snappymail', 'snappymail-password', '');
}
}
}

View file

@ -93,7 +93,7 @@ abstract class NetClient
if ($this->IsConnected()) {
$this->writeLogException(new Exceptions\SocketAlreadyConnectedException, \LOG_ERR, false);
return;
$this->Disconnect();
}
$this->Settings = $oSettings;

View file

@ -40,7 +40,12 @@ trait User
$this->Logger()->AddSecret($sPassword);
$oAccount = $this->LoginProcess($sEmail, $sPassword, $bSignMe);
try {
$oAccount = $this->LoginProcess($sEmail, $sPassword, $bSignMe);
} catch (\Throwable $oException) {
$this->loginErrorDelay();
throw $oException;
}
$this->SetAuthToken($oAccount);

View file

@ -121,7 +121,6 @@ trait UserAuth
$this->resolveLoginCredentials($sEmail, $sPassword, $sLogin);
if (!\str_contains($sEmail, '@') || !\strlen($sPassword)) {
$this->loginErrorDelay();
throw new ClientException(Notifications::InvalidInputArgument);
}
@ -135,20 +134,13 @@ trait UserAuth
}
} catch (\Throwable $oException) {
$this->LoggerAuthHelper($oAccount, $this->getAdditionalLogParamsByUserLogin($sInputEmail));
$this->loginErrorDelay();
throw $oException;
}
try {
$this->imapConnect($oAccount, true);
if ($bMainAccount) {
$bSignMe && $this->SetSignMeToken($oAccount);
$this->StorageProvider()->Put($oAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
}
} catch (\Throwable $oException) {
$this->loginErrorDelay();
throw $oException;
$this->imapConnect($oAccount, true);
if ($bMainAccount) {
$bSignMe && $this->SetSignMeToken($oAccount);
$this->StorageProvider()->Put($oAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
}
return $oAccount;