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

Commit 365a5ef

Browse files
author
the-djmaze
committed
UserAuth prevent plugin errors (like the Nextcloud plugin did)
1 parent 69cd876 commit 365a5ef

File tree

1 file changed

+18
-7
lines changed
  • snappymail/v/0.0.0/app/libraries/RainLoop/Actions

1 file changed

+18
-7
lines changed

snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ protected function resolveLoginCredentials(string $sEmail, SensitiveString $oPas
3737
{
3838
$sEmail = \SnappyMail\IDN::emailToAscii(\MailSo\Base\Utils::Trim($sEmail));
3939

40-
$this->Plugins()->RunHook('login.credentials.step-1', array(&$sEmail));
40+
$sNewEmail = $sEmail;
41+
$this->Plugins()->RunHook('login.credentials.step-1', array(&$sNewEmail));
42+
if ($sNewEmail) {
43+
$sEmail = $sNewEmail;
44+
}
4145

4246
$oDomain = null;
4347
$oDomainProvider = $this->DomainProvider();
@@ -98,9 +102,13 @@ protected function resolveLoginCredentials(string $sEmail, SensitiveString $oPas
98102
}
99103
}
100104

101-
$sPassword = (string) $oPassword;
102-
$this->Plugins()->RunHook('login.credentials.step-2', array(&$sEmail, &$sPassword));
105+
$sNewEmail = $sEmail;
106+
$sPassword = $oPassword->getValue();
107+
$this->Plugins()->RunHook('login.credentials.step-2', array(&$sNewEmail, &$sPassword));
103108
$this->logMask($sPassword);
109+
if ($sNewEmail) {
110+
$sEmail = $sNewEmail;
111+
}
104112

105113
$sImapUser = $sEmail;
106114
$sSmtpUser = $sEmail;
@@ -112,15 +120,18 @@ protected function resolveLoginCredentials(string $sEmail, SensitiveString $oPas
112120
$sSmtpUser = $oDomain->SmtpSettings()->fixUsername($sSmtpUser);
113121
}
114122

115-
$this->Plugins()->RunHook('login.credentials', array(&$sEmail, &$sImapUser, &$sPassword, &$sSmtpUser));
123+
$sNewEmail = $sEmail;
124+
$sNewImapUser = $sImapUser;
125+
$sNewSmtpUser = $sSmtpUser;
126+
$this->Plugins()->RunHook('login.credentials', array(&$sNewEmail, &$sNewImapUser, &$sPassword, &$sNewSmtpUser));
116127

117128
$oPassword->setValue($sPassword);
118129

119130
return [
120-
'email' => $sEmail,
131+
'email' => $sNewEmail ?: $sEmail,
121132
'domain' => $oDomain,
122-
'imapUser' => $sImapUser,
123-
'smtpUser' => $sSmtpUser,
133+
'imapUser' => $sNewImapUser ?: $sImapUser,
134+
'smtpUser' => $sNewSmtpUser ?: $sSmtpUser,
124135
'pass' => $oPassword
125136
];
126137
}

0 commit comments

Comments
 (0)