From 682af34d536a7c85dbdc6fa462e3c9675b2d3863 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Thu, 8 Dec 2022 10:35:20 +0100 Subject: [PATCH] Deprecate Account->Login() and Account->Password() --- plugins/change-password-poppassd/driver.php | 2 +- plugins/change-password/drivers/ldap.php | 6 ++-- plugins/change-password/drivers/pdo.php | 2 +- plugins/change-password/index.php | 2 +- .../LdapContactsSuggestions.php | 4 +-- .../ldap-mail-accounts/LdapMailAccounts.php | 4 +-- plugins/proxyauth-login-example/index.php | 6 ++-- .../app/libraries/RainLoop/Model/Account.php | 28 ++++++++----------- 8 files changed, 25 insertions(+), 29 deletions(-) diff --git a/plugins/change-password-poppassd/driver.php b/plugins/change-password-poppassd/driver.php index 6388f6474..4c4f0c0f6 100644 --- a/plugins/change-password-poppassd/driver.php +++ b/plugins/change-password-poppassd/driver.php @@ -58,7 +58,7 @@ class ChangePasswordPoppassdDriver extends \MailSo\Net\NetClient try { - $this->sendRequestWithCheck('user', $oAccount->Login(), true); + $this->sendRequestWithCheck('user', $oAccount->IncLogin(), true); $this->sendRequestWithCheck('pass', $sPrevPassword, true); } catch (\Throwable $oException) diff --git a/plugins/change-password/drivers/ldap.php b/plugins/change-password/drivers/ldap.php index 591f10251..c53492263 100644 --- a/plugins/change-password/drivers/ldap.php +++ b/plugins/change-password/drivers/ldap.php @@ -64,11 +64,11 @@ class ChangePasswordDriverLDAP '{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); diff --git a/plugins/change-password/drivers/pdo.php b/plugins/change-password/drivers/pdo.php index f9c6a5068..80fbc57dc 100644 --- a/plugins/change-password/drivers/pdo.php +++ b/plugins/change-password/drivers/pdo.php @@ -89,7 +89,7 @@ class ChangePasswordDriverPDO ':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', ''); diff --git a/plugins/change-password/index.php b/plugins/change-password/index.php index aa87c9395..a994e3dd0 100644 --- a/plugins/change-password/index.php +++ b/plugins/change-password/index.php @@ -146,7 +146,7 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin } $sPrevPassword = $this->jsonParam('PrevPassword'); - if ($sPrevPassword !== $oAccount->Password()) { + if ($sPrevPassword !== $oAccount->IncPassword()) { throw new ClientException(static::CurrentPasswordIncorrect, null, $oActions->StaticI18N('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT')); } diff --git a/plugins/ldap-contacts-suggestions/LdapContactsSuggestions.php b/plugins/ldap-contacts-suggestions/LdapContactsSuggestions.php index 645d1f8c3..e977b999c 100644 --- a/plugins/ldap-contacts-suggestions/LdapContactsSuggestions.php +++ b/plugins/ldap-contacts-suggestions/LdapContactsSuggestions.php @@ -222,8 +222,8 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges '{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() )); diff --git a/plugins/ldap-mail-accounts/LdapMailAccounts.php b/plugins/ldap-mail-accounts/LdapMailAccounts.php index 989502e43..d82eec809 100644 --- a/plugins/ldap-mail-accounts/LdapMailAccounts.php +++ b/plugins/ldap-mail-accounts/LdapMailAccounts.php @@ -66,7 +66,7 @@ class LdapMailAccounts // 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; @@ -135,7 +135,7 @@ class LdapMailAccounts { //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); diff --git a/plugins/proxyauth-login-example/index.php b/plugins/proxyauth-login-example/index.php index 675e74900..f0d25878b 100644 --- a/plugins/proxyauth-login-example/index.php +++ b/plugins/proxyauth-login-example/index.php @@ -31,12 +31,12 @@ class ProxyauthLoginExamplePlugin extends \RainLoop\Plugins\AbstractPlugin 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 diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php index 649a74c7d..954afe70c 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php @@ -44,13 +44,9 @@ abstract class Account implements \JsonSerializable 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 @@ -60,22 +56,22 @@ abstract class Account implements \JsonSerializable 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(); } @@ -209,7 +205,7 @@ abstract class Account implements \JsonSerializable $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()); } } @@ -273,7 +269,7 @@ abstract class Account implements \JsonSerializable [cipher_version] => TLSv1.3 ) */ - $oSettings->Password = $this->Password(); + $oSettings->Password = $this->IncPassword(); $oSettings->ProxyAuthUser = $this->ProxyAuthUser(); $oSettings->ProxyAuthPassword = $this->ProxyAuthPassword();