Skip to content

Commit

Permalink
Deprecate Account->Login() and Account->Password()
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Dec 8, 2022
1 parent 6af4ead commit 682af34
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion plugins/change-password-poppassd/driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function ChangePassword(\RainLoop\Model\Account $oAccount, string $sPrevP

try
{
$this->sendRequestWithCheck('user', $oAccount->Login(), true);
$this->sendRequestWithCheck('user', $oAccount->IncLogin(), true);
$this->sendRequestWithCheck('pass', $sPrevPassword, true);
}
catch (\Throwable $oException)
Expand Down
6 changes: 3 additions & 3 deletions plugins/change-password/drivers/ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public function ChangePassword(\RainLoop\Model\Account $oAccount, string $sPrevP
'{email}' => $oAccount->Email(),
'{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()),
'{email:domain}' => $sDomain,
'{login}' => $oAccount->Login(),
'{imap:login}' => $oAccount->Login(),
'{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(),
'{imap:port}' => $oAccount->Domain()->IncPort(),
'{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->Login()) : ''
'{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->IncLogin()) : ''
));

$oCon = \ldap_connect($this->sLdapUri);
Expand Down
2 changes: 1 addition & 1 deletion plugins/change-password/drivers/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function ChangePassword(\RainLoop\Model\Account $oAccount, string $sPrevP
':newpass' => $encrypt_prefix . \ChangePasswordPlugin::encrypt($encrypt, $sNewPassword),
':domain' => \MailSo\Base\Utils::GetDomainFromEmail($sEmail),
':username' => \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail),
':login_name' => $oAccount->Login()
':login_name' => $oAccount->IncLogin()
);

$sql = $this->oConfig->Get('plugin', 'pdo_sql', '');
Expand Down
2 changes: 1 addition & 1 deletion plugins/change-password/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function ChangePassword()
}

$sPrevPassword = $this->jsonParam('PrevPassword');
if ($sPrevPassword !== $oAccount->Password()) {
if ($sPrevPassword !== $oAccount->IncPassword()) {
throw new ClientException(static::CurrentPasswordIncorrect, null, $oActions->StaticI18N('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT'));
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/ldap-contacts-suggestions/LdapContactsSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ private function ldapSearch($oAccount, $sQuery)
'{email}' => $oAccount->Email(),
'{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()),
'{email:domain}' => $sDomain,
'{login}' => $oAccount->Login(),
'{imap:login}' => $oAccount->Login(),
'{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(),
'{imap:port}' => $oAccount->Domain()->IncPort()
));
Expand Down
4 changes: 2 additions & 2 deletions plugins/ldap-mail-accounts/LdapMailAccounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function AddLdapMailAccounts(MainAccount $oAccount): bool

// Try to get account information. Login() returns the username of the user
// and removes the domainname if this was configured inside the domain config.
$username = @ldap_escape($oAccount->Login(), "", LDAP_ESCAPE_FILTER);
$username = @ldap_escape($oAccount->IncLogin(), "", LDAP_ESCAPE_FILTER);

$searchString = $this->config->search_string;

Expand Down Expand Up @@ -135,7 +135,7 @@ public function AddLdapMailAccounts(MainAccount $oAccount): bool
{
//Try to login the user with the same password as the primary account has
//if this fails the user will see the new mail addresses but will be asked for the correct password
$sPass = $oAccount->Password();
$sPass = $oAccount->IncPassword();

$oNewAccount = RainLoop\Model\AdditionalAccount::NewInstanceFromCredentials($oActions, "$sUsername@$sDomain", $sUsername, $sPass);

Expand Down
6 changes: 3 additions & 3 deletions plugins/proxyauth-login-example/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function EventLoginPostLoginProvide(&$oAccount)
if ($oAccount instanceof \RainLoop\Model\Account)
{
// Verify logic
$bValid = $this->isValidAccount($oAccount->Login(), $oAccount->Password());
$bValid = $this->isValidAccount($oAccount->IncLogin(), $oAccount->IncPassword());

/**
* $oAccount->Email(); // Email (It is not a IMAP login)
* $oAccount->Login(); // IMAP login
* $oAccount->Password(); // IMAP password
* $oAccount->IncLogin(); // IMAP login
* $oAccount->IncPassword(); // IMAP password
* $oAccount->Domain()->IncHost(); // IMAP host
*
* @see \RainLoo\Model\Account for more
Expand Down
28 changes: 12 additions & 16 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ public function ProxyAuthPassword() : string

public function IncLogin() : string
{
$sLogin = $this->sLogin;
if ($this->oDomain->IncShortLogin())
{
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}

return $sLogin;
return $this->oDomain->IncShortLogin()
? \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin)
: $this->sLogin;
}

public function IncPassword() : string
Expand All @@ -60,22 +56,22 @@ public function IncPassword() : string

public function OutLogin() : string
{
$sLogin = $this->sLogin;
if ($this->oDomain->OutShortLogin())
{
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}

return $sLogin;
return $this->oDomain->OutShortLogin()
? \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin)
: $this->sLogin;
}

// Deprecated
public function Login() : string
{
\trigger_error('Use \RainLoop\Model\Account->IncLogin()', \E_USER_DEPRECATED);
return $this->IncLogin();
}

// Deprecated
public function Password() : string
{
\trigger_error('Use \RainLoop\Model\Account->IncPassword()', \E_USER_DEPRECATED);
return $this->IncPassword();
}

Expand Down Expand Up @@ -209,7 +205,7 @@ public static function NewInstanceFromTokenArray(
$oAccount->sProxyAuthUser = $aAccountHash['proxy']['user'];
$oAccount->sProxyAuthPassword = $aAccountHash['proxy']['pass'];
}
$oActions->Logger()->AddSecret($oAccount->Password());
$oActions->Logger()->AddSecret($oAccount->IncPassword());
$oActions->Logger()->AddSecret($oAccount->ProxyAuthPassword());
}
}
Expand Down Expand Up @@ -273,7 +269,7 @@ private function netClientLogin(\MailSo\Net\NetClient $oClient, \RainLoop\Plugin
[cipher_version] => TLSv1.3
)
*/
$oSettings->Password = $this->Password();
$oSettings->Password = $this->IncPassword();
$oSettings->ProxyAuthUser = $this->ProxyAuthUser();
$oSettings->ProxyAuthPassword = $this->ProxyAuthPassword();

Expand Down

0 comments on commit 682af34

Please sign in to comment.