@@ -144,28 +144,34 @@ public static function NewInstanceFromTokenArray(
144
144
{
145
145
$ oAccount = null ;
146
146
$ 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');
167
157
}
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
+ }
169
175
if (isset ($ aAccountHash ['name ' ])) {
170
176
$ oAccount ->sName = $ aAccountHash ['name ' ];
171
177
}
@@ -177,6 +183,11 @@ public static function NewInstanceFromTokenArray(
177
183
$ oAccount ->setSmtpPass (new SensitiveString ($ aAccountHash ['smtp ' ]['pass ' ]));
178
184
}
179
185
}
186
+ } catch (\Throwable $ e ) {
187
+ \SnappyMail \Log::debug ('ACCOUNT ' , $ e ->getMessage ());
188
+ if ($ bThrowExceptionOnFalse ) {
189
+ throw $ e ;
190
+ }
180
191
}
181
192
return $ oAccount ;
182
193
}
0 commit comments