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 try
{ {
$this->sendRequestWithCheck('user', $oAccount->Login(), true); $this->sendRequestWithCheck('user', $oAccount->IncLogin(), true);
$this->sendRequestWithCheck('pass', $sPrevPassword, true); $this->sendRequestWithCheck('pass', $sPrevPassword, true);
} }
catch (\Throwable $oException) catch (\Throwable $oException)

View file

@ -64,11 +64,11 @@ class ChangePasswordDriverLDAP
'{email}' => $oAccount->Email(), '{email}' => $oAccount->Email(),
'{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()), '{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()),
'{email:domain}' => $sDomain, '{email:domain}' => $sDomain,
'{login}' => $oAccount->Login(), '{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->Login(), '{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(), '{imap:host}' => $oAccount->Domain()->IncHost(),
'{imap:port}' => $oAccount->Domain()->IncPort(), '{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); $oCon = \ldap_connect($this->sLdapUri);

View file

@ -89,7 +89,7 @@ class ChangePasswordDriverPDO
':newpass' => $encrypt_prefix . \ChangePasswordPlugin::encrypt($encrypt, $sNewPassword), ':newpass' => $encrypt_prefix . \ChangePasswordPlugin::encrypt($encrypt, $sNewPassword),
':domain' => \MailSo\Base\Utils::GetDomainFromEmail($sEmail), ':domain' => \MailSo\Base\Utils::GetDomainFromEmail($sEmail),
':username' => \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail), ':username' => \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail),
':login_name' => $oAccount->Login() ':login_name' => $oAccount->IncLogin()
); );
$sql = $this->oConfig->Get('plugin', 'pdo_sql', ''); $sql = $this->oConfig->Get('plugin', 'pdo_sql', '');

View file

@ -146,7 +146,7 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
} }
$sPrevPassword = $this->jsonParam('PrevPassword'); $sPrevPassword = $this->jsonParam('PrevPassword');
if ($sPrevPassword !== $oAccount->Password()) { if ($sPrevPassword !== $oAccount->IncPassword()) {
throw new ClientException(static::CurrentPasswordIncorrect, null, $oActions->StaticI18N('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT')); 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}' => $oAccount->Email(),
'{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()), '{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()),
'{email:domain}' => $sDomain, '{email:domain}' => $sDomain,
'{login}' => $oAccount->Login(), '{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->Login(), '{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(), '{imap:host}' => $oAccount->Domain()->IncHost(),
'{imap:port}' => $oAccount->Domain()->IncPort() '{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 // Try to get account information. Login() returns the username of the user
// and removes the domainname if this was configured inside the domain config. // 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; $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 //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 //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); $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) if ($oAccount instanceof \RainLoop\Model\Account)
{ {
// Verify logic // 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->Email(); // Email (It is not a IMAP login)
* $oAccount->Login(); // IMAP login * $oAccount->IncLogin(); // IMAP login
* $oAccount->Password(); // IMAP password * $oAccount->IncPassword(); // IMAP password
* $oAccount->Domain()->IncHost(); // IMAP host * $oAccount->Domain()->IncHost(); // IMAP host
* *
* @see \RainLoo\Model\Account for more * @see \RainLoo\Model\Account for more

View file

@ -44,13 +44,9 @@ abstract class Account implements \JsonSerializable
public function IncLogin() : string public function IncLogin() : string
{ {
$sLogin = $this->sLogin; return $this->oDomain->IncShortLogin()
if ($this->oDomain->IncShortLogin()) ? \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin)
{ : $this->sLogin;
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}
return $sLogin;
} }
public function IncPassword() : string public function IncPassword() : string
@ -60,22 +56,22 @@ abstract class Account implements \JsonSerializable
public function OutLogin() : string public function OutLogin() : string
{ {
$sLogin = $this->sLogin; return $this->oDomain->OutShortLogin()
if ($this->oDomain->OutShortLogin()) ? \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin)
{ : $this->sLogin;
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}
return $sLogin;
} }
// Deprecated
public function Login() : string public function Login() : string
{ {
\trigger_error('Use \RainLoop\Model\Account->IncLogin()', \E_USER_DEPRECATED);
return $this->IncLogin(); return $this->IncLogin();
} }
// Deprecated
public function Password() : string public function Password() : string
{ {
\trigger_error('Use \RainLoop\Model\Account->IncPassword()', \E_USER_DEPRECATED);
return $this->IncPassword(); return $this->IncPassword();
} }
@ -209,7 +205,7 @@ abstract class Account implements \JsonSerializable
$oAccount->sProxyAuthUser = $aAccountHash['proxy']['user']; $oAccount->sProxyAuthUser = $aAccountHash['proxy']['user'];
$oAccount->sProxyAuthPassword = $aAccountHash['proxy']['pass']; $oAccount->sProxyAuthPassword = $aAccountHash['proxy']['pass'];
} }
$oActions->Logger()->AddSecret($oAccount->Password()); $oActions->Logger()->AddSecret($oAccount->IncPassword());
$oActions->Logger()->AddSecret($oAccount->ProxyAuthPassword()); $oActions->Logger()->AddSecret($oAccount->ProxyAuthPassword());
} }
} }
@ -273,7 +269,7 @@ abstract class Account implements \JsonSerializable
[cipher_version] => TLSv1.3 [cipher_version] => TLSv1.3
) )
*/ */
$oSettings->Password = $this->Password(); $oSettings->Password = $this->IncPassword();
$oSettings->ProxyAuthUser = $this->ProxyAuthUser(); $oSettings->ProxyAuthUser = $this->ProxyAuthUser();
$oSettings->ProxyAuthPassword = $this->ProxyAuthPassword(); $oSettings->ProxyAuthPassword = $this->ProxyAuthPassword();