mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Changes for #1128
This commit is contained in:
parent
a504fd9298
commit
35bfff878d
3 changed files with 59 additions and 51 deletions
|
|
@ -35,34 +35,26 @@ class ChangePasswordHestiaDriver
|
|||
->SetDescription('Ex: localhost or domain.com'),
|
||||
\RainLoop\Plugins\Property::NewInstance('hestia_port')->SetLabel('Hestia Port')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
|
||||
->SetDefaultValue(8083),
|
||||
\RainLoop\Plugins\Property::NewInstance('hestia_allowed_emails')->SetLabel('Allowed emails')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
||||
->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: user1@domain1.net user2@domain1.net *@domain2.net')
|
||||
->SetDefaultValue('*')
|
||||
->SetDefaultValue(8083)
|
||||
);
|
||||
}
|
||||
|
||||
public function ChangePassword(\RainLoop\Model\Account $oAccount, string $sPrevPassword, string $sNewPassword) : bool
|
||||
{
|
||||
if (!\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $this->oConfig->Get('plugin', 'hestia_allowed_emails', ''))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sHost = $this->oConfig->Get('plugin', 'hestia_login');
|
||||
$sPort = $this->oConfig->Get('plugin', 'hestia_port');
|
||||
|
||||
$HTTP = \SnappyMail\HTTP\Request::factory();
|
||||
$postvars = array(
|
||||
'email' => $oAccount->Email(),
|
||||
'password' => $sPrevPassword,
|
||||
'new' => $sNewPassword,
|
||||
);
|
||||
$cRequest = $HTTP->doRequest('POST','https://'.$sHost.':'.$sPort.'/reset/mail/',http_build_query($postvars));
|
||||
if($cRequest -> body == '==ok=='){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$sHost = $this->oConfig->Get('plugin', 'hestia_login');
|
||||
$sPort = $this->oConfig->Get('plugin', 'hestia_port');
|
||||
|
||||
$HTTP = \SnappyMail\HTTP\Request::factory();
|
||||
$postvars = array(
|
||||
'email' => $oAccount->Email(),
|
||||
'password' => $sPrevPassword,
|
||||
'new' => $sNewPassword,
|
||||
);
|
||||
$cRequest = $HTTP->doRequest('POST','https://'.$sHost.':'.$sPort.'/reset/mail/',http_build_query($postvars));
|
||||
return '==ok==' == $cRequest->body;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue