mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
Some fixes (ChangePasswordCustomSql Plugin)
This commit is contained in:
parent
c0aa67dc52
commit
cbc1aa2f4c
6 changed files with 35 additions and 50 deletions
|
@ -117,7 +117,7 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
*
|
||||
|
@ -125,8 +125,7 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor
|
|||
*/
|
||||
public function PasswordChangePossibility($oAccount)
|
||||
{
|
||||
return $oAccount && $oAccount->Email() &&
|
||||
\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $this->sAllowedEmails);
|
||||
return $oAccount && $oAccount->Email();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,45 +156,35 @@ class ChangePasswordCustomSqlDriver implements \RainLoop\Providers\ChangePasswor
|
|||
$conn = new PDO($dsn,$this->mUser,$this->mPass,$options);
|
||||
|
||||
//prepare SQL varaibles
|
||||
$sEmail = $oAccount->Email();
|
||||
$sEmail = $oAccount->Email();
|
||||
$sEmailUser = \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail);
|
||||
$sEmailDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
|
||||
|
||||
//simple check
|
||||
|
||||
$old = array(':email', ':oldpass', ':newpass', ':domain', ':username', ':table' );
|
||||
$new = array($sEmail, $sPrevPassword, $sNewPassword, $sEmailDomain, $sEmailUser, $this->mTable);
|
||||
|
||||
$this->mSql = str_replace($old, $new, $this->mSql);
|
||||
|
||||
$update = $conn->prepare($this->mSql);
|
||||
$mSqlReturn = $update->execute(array());
|
||||
/* $mSqlReturn = $update->execute(array(
|
||||
':email' => $sEmail,
|
||||
':oldpass' => $sPrevPassword,
|
||||
':newpass' => $sNewPassword,
|
||||
':domain' => $sEmailDomain,
|
||||
':username' => $sEmailUser,
|
||||
':table' => $this->mTable
|
||||
));
|
||||
*/
|
||||
if ($mSqlReturn == true)
|
||||
{
|
||||
$bResult = true;
|
||||
if ($this->oLogger)
|
||||
{
|
||||
$this->oLogger->Write('Success! Password changed.');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bResult = false;
|
||||
if ($this->oLogger)
|
||||
{
|
||||
$this->oLogger->Write('Something went wrong. Either current password is incorrect, or new password does not match criteria.');
|
||||
}
|
||||
}
|
||||
$old = array(':email', ':oldpass', ':newpass', ':domain', ':username', ':table' );
|
||||
$new = array($sEmail, $sPrevPassword, $sNewPassword, $sEmailDomain, $sEmailUser, $this->mTable);
|
||||
|
||||
$this->mSql = str_replace($old, $new, $this->mSql);
|
||||
|
||||
$update = $conn->prepare($this->mSql);
|
||||
$mSqlReturn = $update->execute(array());
|
||||
if ($mSqlReturn == true)
|
||||
{
|
||||
$bResult = true;
|
||||
if ($this->oLogger)
|
||||
{
|
||||
$this->oLogger->Write('Success! Password changed.');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bResult = false;
|
||||
if ($this->oLogger)
|
||||
{
|
||||
$this->oLogger->Write('Something went wrong. Either current password is incorrect, or new password does not match criteria.');
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
|
@ -5,6 +5,6 @@ This plugin adds change password capability to Rainloop webmail by write your ow
|
|||
|
||||
##### Installation is simple:
|
||||
|
||||
1. Drop the change-password-customsql in the plugins directory (eg. _RainLoopDir_/data/data_xxxxx/_default/plugins/*)
|
||||
2. In rainloop admin panel go to Plugins, and activate change-password-customsql.
|
||||
1. Drop the change-password-custom-sql in the plugins directory (eg. _RainLoopDir_/data/data_xxxxx/_default/plugins/*)
|
||||
2. In rainloop admin panel go to Plugins, and activate change-password-custom-sql.
|
||||
3. Enter mysql details on the plugin config screen.
|
|
@ -16,21 +16,17 @@ class ChangePasswordCustomSqlPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
switch ($sName)
|
||||
{
|
||||
case 'change-password':
|
||||
|
||||
include_once __DIR__.'/ChangePasswordCustomSqlDriver.php';
|
||||
|
||||
$oProvider = new ChangePasswordCustomSqlDriver();
|
||||
|
||||
$oProvider
|
||||
->SetLogger($this->Manager()->Actions()->Logger())
|
||||
->SetmHost($this->Config()->Get('plugin', 'mHost', ''))
|
||||
->SetmUser($this->Config()->Get('plugin', 'mUser', ''))
|
||||
->SetmPass($this->Config()->Get('plugin', 'mPass', ''))
|
||||
->SetmDatabase($this->Config()->Get('plugin', 'mDatabase', ''))
|
||||
->SetmTable($this->Config()->Get('plugin', 'mTable', ''))
|
||||
->SetmSql($this->Config()->Get('plugin', 'mSql', ''))
|
||||
->SetLogger($this->Manager()->Actions()->Logger())
|
||||
->SetmHost($this->Config()->Get('plugin', 'mHost', ''))
|
||||
->SetmUser($this->Config()->Get('plugin', 'mUser', ''))
|
||||
->SetmPass($this->Config()->Get('plugin', 'mPass', ''))
|
||||
->SetmDatabase($this->Config()->Get('plugin', 'mDatabase', ''))
|
||||
->SetmTable($this->Config()->Get('plugin', 'mTable', ''))
|
||||
->SetmSql($this->Config()->Get('plugin', 'mSql', ''))
|
||||
;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +46,7 @@ class ChangePasswordCustomSqlPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
\RainLoop\Plugins\Property::NewInstance('mTable')->SetLabel('MySQL Table'),
|
||||
\RainLoop\Plugins\Property::NewInstance('mSql')->SetLabel('SQL statement')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
||||
->SetDescription('SQL statement (allowed wildcards :table, :email, :oldpass, :newpass, :domain, :username).When using MD5 OR SHA1 at tables, write it directly here as SQL functions. Fro non-SQL encryptions use another plugin or wait for new version.')
|
||||
->SetDescription('SQL statement (allowed wildcards :table, :email, :oldpass, :newpass, :domain, :username). When using MD5 OR SHA1 at tables, write it directly here as SQL functions. Fro non-SQL encryptions use another plugin or wait for new version.')
|
||||
->SetDefaultValue('UPDATE :table SET password = md5(:newpass) WHERE domain = :domain AND username = :username and oldpass = md5(:oldpass)')
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue