Skip to content

Commit

Permalink
UserAuth prevent plugin errors (like the Nextcloud plugin did)
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed May 27, 2024
1 parent 69cd876 commit 365a5ef
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ protected function resolveLoginCredentials(string $sEmail, SensitiveString $oPas
{
$sEmail = \SnappyMail\IDN::emailToAscii(\MailSo\Base\Utils::Trim($sEmail));

$this->Plugins()->RunHook('login.credentials.step-1', array(&$sEmail));
$sNewEmail = $sEmail;
$this->Plugins()->RunHook('login.credentials.step-1', array(&$sNewEmail));
if ($sNewEmail) {
$sEmail = $sNewEmail;
}

$oDomain = null;
$oDomainProvider = $this->DomainProvider();
Expand Down Expand Up @@ -98,9 +102,13 @@ protected function resolveLoginCredentials(string $sEmail, SensitiveString $oPas
}
}

$sPassword = (string) $oPassword;
$this->Plugins()->RunHook('login.credentials.step-2', array(&$sEmail, &$sPassword));
$sNewEmail = $sEmail;
$sPassword = $oPassword->getValue();
$this->Plugins()->RunHook('login.credentials.step-2', array(&$sNewEmail, &$sPassword));
$this->logMask($sPassword);
if ($sNewEmail) {
$sEmail = $sNewEmail;
}

$sImapUser = $sEmail;
$sSmtpUser = $sEmail;
Expand All @@ -112,15 +120,18 @@ protected function resolveLoginCredentials(string $sEmail, SensitiveString $oPas
$sSmtpUser = $oDomain->SmtpSettings()->fixUsername($sSmtpUser);
}

$this->Plugins()->RunHook('login.credentials', array(&$sEmail, &$sImapUser, &$sPassword, &$sSmtpUser));
$sNewEmail = $sEmail;
$sNewImapUser = $sImapUser;
$sNewSmtpUser = $sSmtpUser;
$this->Plugins()->RunHook('login.credentials', array(&$sNewEmail, &$sNewImapUser, &$sPassword, &$sNewSmtpUser));

$oPassword->setValue($sPassword);

return [
'email' => $sEmail,
'email' => $sNewEmail ?: $sEmail,
'domain' => $oDomain,
'imapUser' => $sImapUser,
'smtpUser' => $sSmtpUser,
'imapUser' => $sNewImapUser ?: $sImapUser,
'smtpUser' => $sNewSmtpUser ?: $sSmtpUser,
'pass' => $oPassword
];
}
Expand Down

0 comments on commit 365a5ef

Please sign in to comment.