Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 16cc17a

Browse files
author
the-djmaze
committed
Change for #1706 to debug more
1 parent e3c53f8 commit 16cc17a

File tree

1 file changed

+32
-21
lines changed
  • snappymail/v/0.0.0/app/libraries/RainLoop/Model

1 file changed

+32
-21
lines changed

snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -144,28 +144,34 @@ public static function NewInstanceFromTokenArray(
144144
{
145145
$oAccount = null;
146146
$aAccountHash = static::convertArray($aAccountHash);
147-
if (!empty($aAccountHash['email']) && !empty($aAccountHash['login']) && !empty($aAccountHash['pass'])) {
148-
try {
149-
$oDomain = $oActions->DomainProvider()->getByEmailAddress($aAccountHash['email']);
150-
if ($oDomain) {
151-
// $aAccountHash['email'] = $oDomain->ImapSettings()->fixUsername($aAccountHash['email'], false);
152-
// $aAccountHash['login'] = $oDomain->ImapSettings()->fixUsername($aAccountHash['login']);
153-
$oAccount = new static;
154-
$oAccount->sEmail = \SnappyMail\IDN::emailToAscii($aAccountHash['email']);
155-
$oAccount->sImapUser = \SnappyMail\IDN::emailToAscii($aAccountHash['login']);
156-
$oAccount->setImapPass(new SensitiveString($aAccountHash['pass']));
157-
$oAccount->oDomain = $oDomain;
158-
$oActions->Plugins()->RunHook('filter.account', array($oAccount));
159-
if ($bThrowExceptionOnFalse && !$oAccount) {
160-
throw new ClientException(Notifications::AccountFilterError);
161-
}
162-
}
163-
} catch (\Throwable $e) {
164-
if ($bThrowExceptionOnFalse) {
165-
throw $e;
166-
}
147+
try {
148+
/*
149+
if (empty($aAccountHash['email'])) {
150+
throw new ClientException(Notifications::InvalidToken, null, 'TokenArray missing email');
151+
}
152+
if (empty($aAccountHash['login'])) {
153+
throw new ClientException(Notifications::InvalidToken, null, 'TokenArray missing login');
154+
}
155+
if (empty($aAccountHash['pass'])) {
156+
throw new ClientException(Notifications::InvalidToken, null, 'TokenArray missing pass');
167157
}
168-
if ($oAccount) {
158+
*/
159+
if (empty($aAccountHash['email']) || empty($aAccountHash['login']) || empty($aAccountHash['pass'])) {
160+
throw new \RuntimeException("Invalid TokenArray");
161+
}
162+
$oDomain = $oActions->DomainProvider()->getByEmailAddress($aAccountHash['email']);
163+
if ($oDomain) {
164+
// $aAccountHash['email'] = $oDomain->ImapSettings()->fixUsername($aAccountHash['email'], false);
165+
// $aAccountHash['login'] = $oDomain->ImapSettings()->fixUsername($aAccountHash['login']);
166+
$oAccount = new static;
167+
$oAccount->sEmail = \SnappyMail\IDN::emailToAscii($aAccountHash['email']);
168+
$oAccount->sImapUser = \SnappyMail\IDN::emailToAscii($aAccountHash['login']);
169+
$oAccount->setImapPass(new SensitiveString($aAccountHash['pass']));
170+
$oAccount->oDomain = $oDomain;
171+
$oActions->Plugins()->RunHook('filter.account', array($oAccount));
172+
if (!$oAccount) {
173+
throw new ClientException(Notifications::AccountFilterError);
174+
}
169175
if (isset($aAccountHash['name'])) {
170176
$oAccount->sName = $aAccountHash['name'];
171177
}
@@ -177,6 +183,11 @@ public static function NewInstanceFromTokenArray(
177183
$oAccount->setSmtpPass(new SensitiveString($aAccountHash['smtp']['pass']));
178184
}
179185
}
186+
} catch (\Throwable $e) {
187+
\SnappyMail\Log::debug('ACCOUNT', $e->getMessage());
188+
if ($bThrowExceptionOnFalse) {
189+
throw $e;
190+
}
180191
}
181192
return $oAccount;
182193
}

0 commit comments

Comments
 (0)