Deprecate Account->Login() and Account->Password()

This commit is contained in:
the-djmaze 2022-12-08 10:35:20 +01:00
parent 6af4ead706
commit 682af34d53
8 changed files with 25 additions and 29 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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', '');

View file

@ -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'));
}

View file

@ -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()
));

View file

@ -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);

View file

@ -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

View file

@ -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();