mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Merge pull request #120 from Alphix/improve_change_password
[change-password] Improve change password Last .js change is correct. It was a leftover of the old RainLoop AuthAccountHash system. AuthAccountHash was some kind of login hash system to get logged in mail account.
This commit is contained in:
commit
f0549e1735
3 changed files with 18 additions and 15 deletions
|
|
@ -7,8 +7,8 @@ class ChangePasswordDriverLDAP
|
||||||
DESCRIPTION = 'Change passwords in LDAP.';
|
DESCRIPTION = 'Change passwords in LDAP.';
|
||||||
|
|
||||||
private
|
private
|
||||||
$sHostName = 'localhost',
|
$sLdapUri = 'ldap://localhost:389',
|
||||||
$iHostPort = 389,
|
$bUseStartTLS = True,
|
||||||
$sUserDnFormat = '',
|
$sUserDnFormat = '',
|
||||||
$sPasswordField = 'userPassword',
|
$sPasswordField = 'userPassword',
|
||||||
$sPasswordEncType = 'SHA';
|
$sPasswordEncType = 'SHA';
|
||||||
|
|
@ -21,8 +21,8 @@ class ChangePasswordDriverLDAP
|
||||||
function __construct(\RainLoop\Config\Plugin $oConfig, \MailSo\Log\Logger $oLogger)
|
function __construct(\RainLoop\Config\Plugin $oConfig, \MailSo\Log\Logger $oLogger)
|
||||||
{
|
{
|
||||||
$this->oLogger = $oLogger;
|
$this->oLogger = $oLogger;
|
||||||
$this->sHostName = \trim($oConfig->Get('plugin', 'ldap_hostname', ''));
|
$this->sLdapUri = \trim($oConfig->Get('plugin', 'ldap_uri', ''));
|
||||||
$this->iHostPort = (int) $oConfig->Get('plugin', 'ldap_port', 389);
|
$this->bUseStartTLS = (bool) \trim($oConfig->Get('plugin', 'ldap_use_start_tls', ''));
|
||||||
$this->sUserDnFormat = \trim($oConfig->Get('plugin', 'ldap_user_dn_format', ''));
|
$this->sUserDnFormat = \trim($oConfig->Get('plugin', 'ldap_user_dn_format', ''));
|
||||||
$this->sPasswordField = \trim($oConfig->Get('plugin', 'ldap_password_field', ''));
|
$this->sPasswordField = \trim($oConfig->Get('plugin', 'ldap_password_field', ''));
|
||||||
$this->sPasswordEncType = \trim($oConfig->Get('plugin', 'ldap_password_enc_type', ''));
|
$this->sPasswordEncType = \trim($oConfig->Get('plugin', 'ldap_password_enc_type', ''));
|
||||||
|
|
@ -37,11 +37,12 @@ class ChangePasswordDriverLDAP
|
||||||
public static function configMapping() : array
|
public static function configMapping() : array
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
\RainLoop\Plugins\Property::NewInstance('ldap_hostname')->SetLabel('Hostname')
|
\RainLoop\Plugins\Property::NewInstance('ldap_uri')->SetLabel('LDAP URI')
|
||||||
->SetDefaultValue('localhost'),
|
->SetDefaultValue('ldap://localhost:389')
|
||||||
\RainLoop\Plugins\Property::NewInstance('ldap_port')->SetLabel('Port')
|
->SetDescription('LDAP server URI(s), space separated'),
|
||||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
|
\RainLoop\Plugins\Property::NewInstance('ldap_use_start_tls')->SetLabel('Use StartTLS')
|
||||||
->SetDefaultValue(389),
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||||
|
->SetDefaultValue(True),
|
||||||
\RainLoop\Plugins\Property::NewInstance('ldap_user_dn_format')->SetLabel('User DN format')
|
\RainLoop\Plugins\Property::NewInstance('ldap_user_dn_format')->SetLabel('User DN format')
|
||||||
->SetDescription('LDAP user dn format. Supported tokens: {email}, {email:user}, {email:domain}, {login}, {domain}, {domain:dc}, {imap:login}, {imap:host}, {imap:port}, {gecos}')
|
->SetDescription('LDAP user dn format. Supported tokens: {email}, {email:user}, {email:domain}, {login}, {domain}, {domain:dc}, {imap:login}, {imap:host}, {imap:port}, {gecos}')
|
||||||
->SetDefaultValue('uid={imap:login},ou=Users,{domain:dc}'),
|
->SetDefaultValue('uid={imap:login},ou=Users,{domain:dc}'),
|
||||||
|
|
@ -70,7 +71,7 @@ class ChangePasswordDriverLDAP
|
||||||
'{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->Login()) : ''
|
'{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->Login()) : ''
|
||||||
));
|
));
|
||||||
|
|
||||||
$oCon = \ldap_connect($this->sHostName, $this->iHostPort);
|
$oCon = \ldap_connect($this->sLdapUri);
|
||||||
if (!$oCon) {
|
if (!$oCon) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -82,8 +83,10 @@ class ChangePasswordDriverLDAP
|
||||||
'LDAP'
|
'LDAP'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (!\ldap_start_tls($oCon)) {
|
|
||||||
$this->oLogger->Write("ldap_start_tls failed: ".$oCon, \MailSo\Log\Enumerations\Type::WARNING, 'LDAP');
|
if ($this->bUseStartTLS && !@\ldap_start_tls($oCon))
|
||||||
|
{
|
||||||
|
throw new \Exception('ldap_start_tls error '.\ldap_errno($oCon).': '.\ldap_error($oCon));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\ldap_bind($oCon, $sUserDn, $sPrevPassword)) {
|
if (!\ldap_bind($oCon, $sUserDn, $sPrevPassword)) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Change Password',
|
NAME = 'Change Password',
|
||||||
VERSION = '2.2',
|
VERSION = '2.3',
|
||||||
RELEASE = '2021-07-20',
|
RELEASE = '2021-07-20',
|
||||||
REQUIRED = '2.5.0',
|
REQUIRED = '2.5.0',
|
||||||
CATEGORY = 'Security',
|
CATEGORY = 'Security',
|
||||||
|
|
@ -99,7 +99,8 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}_enabled")
|
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}_enabled")
|
||||||
->SetLabel('Enable ' . $class::NAME)
|
->SetLabel('Enable ' . $class::NAME)
|
||||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||||
->SetDescription($class::DESCRIPTION);
|
->SetDescription($class::DESCRIPTION)
|
||||||
|
->SetDefaultValue(false);
|
||||||
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}_allowed_emails")
|
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}_allowed_emails")
|
||||||
->SetLabel('Allowed emails')
|
->SetLabel('Allowed emails')
|
||||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,6 @@
|
||||||
this.newPassword('');
|
this.newPassword('');
|
||||||
this.newPassword2('');
|
this.newPassword2('');
|
||||||
this.passwordUpdateSuccess(true);
|
this.passwordUpdateSuccess(true);
|
||||||
rl.hash.set();
|
|
||||||
rl.settings.set('AuthAccountHash', data.Result);
|
rl.settings.set('AuthAccountHash', data.Result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue