mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Fix cPanel automate login issue
This commit is contained in:
parent
cd66ce1d28
commit
29473045f8
2 changed files with 21 additions and 6 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
url: "/3rdparty/snappymail/"
|
url: "/3rdparty/snappymail/?RemoteAutoLogin"
|
||||||
displayname: "SnappyMail"
|
displayname: "SnappyMail"
|
||||||
icon: "/3rdparty/snappymail/snappymail/v/2.22.1/static/logo-text.png"
|
icon: "/3rdparty/snappymail/snappymail/v/2.22.1/static/logo-text.png"
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ class LoginRemotePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
NAME = 'Login Remote',
|
NAME = 'Login Remote',
|
||||||
AUTHOR = 'SnappyMail',
|
AUTHOR = 'SnappyMail',
|
||||||
URL = 'https://snappymail.eu/',
|
URL = 'https://snappymail.eu/',
|
||||||
VERSION = '1.0',
|
VERSION = '1.1',
|
||||||
RELEASE = '2022-11-11',
|
RELEASE = '2022-11-24',
|
||||||
REQUIRED = '2.21.0',
|
REQUIRED = '2.21.0',
|
||||||
CATEGORY = 'Login',
|
CATEGORY = 'Login',
|
||||||
LICENSE = 'MIT',
|
LICENSE = 'MIT',
|
||||||
|
|
@ -17,15 +17,18 @@ class LoginRemotePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
$this->addPartHook('RemoteAutoLogin', 'ServiceRemoteAutoLogin');
|
$this->addPartHook('RemoteAutoLogin', 'ServiceRemoteAutoLogin');
|
||||||
$this->addHook('filter.app-data', 'FilterAppData');
|
$this->addHook('filter.app-data', 'FilterAppData');
|
||||||
|
$this->addHook('login.credentials', 'FilterLoginCredentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function FilterAppData($bAdmin, &$aResult)
|
public function FilterAppData($bAdmin, &$aResult)
|
||||||
{
|
{
|
||||||
if (!$bAdmin && \is_array($aResult) && empty($aResult['Auth']) && isset($_ENV['REMOTE_USER'])) {
|
if (!$bAdmin && \is_array($aResult) && empty($aResult['Auth']) && isset($_ENV['REMOTE_USER'])) {
|
||||||
$aResult['DevEmail'] = $this->Config()->Get('plugin', 'email', $_ENV['REMOTE_USER']);
|
$aResult['DevEmail'] = $_ENV['REMOTE_USER'];
|
||||||
|
// $aResult['DevPassword'] = $_ENV['REMOTE_PASSWORD'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool $login = false;
|
||||||
public function ServiceRemoteAutoLogin() : bool
|
public function ServiceRemoteAutoLogin() : bool
|
||||||
{
|
{
|
||||||
$oActions = \RainLoop\Api::Actions();
|
$oActions = \RainLoop\Api::Actions();
|
||||||
|
|
@ -36,10 +39,10 @@ class LoginRemotePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
$sEmail = $_ENV['REMOTE_USER'] ?? '';
|
$sEmail = $_ENV['REMOTE_USER'] ?? '';
|
||||||
$sPassword = $_ENV['REMOTE_PASSWORD'] ?? '';
|
$sPassword = $_ENV['REMOTE_PASSWORD'] ?? '';
|
||||||
|
|
||||||
if (\strlen($sEmail) && \strlen($sPassword))
|
if (\strlen($sEmail) && \strlen($sPassword)) {
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
static::$login = true;
|
||||||
$oAccount = $oActions->LoginProcess($sEmail, $sPassword);
|
$oAccount = $oActions->LoginProcess($sEmail, $sPassword);
|
||||||
if ($oAccount instanceof \RainLoop\Model\MainAccount) {
|
if ($oAccount instanceof \RainLoop\Model\MainAccount) {
|
||||||
$oActions->SetAuthToken($oAccount);
|
$oActions->SetAuthToken($oAccount);
|
||||||
|
|
@ -56,4 +59,16 @@ class LoginRemotePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function FilterLoginCredentials(&$sEmail, &$sLogin, &$sPassword)
|
||||||
|
{
|
||||||
|
// cPanel https://github.com/the-djmaze/snappymail/issues/697
|
||||||
|
if (static::$login/* && $sLogin == $_SERVER['REMOTE_USER']*/) {
|
||||||
|
$iPos = \strpos($sPassword, '[::cpses::]');
|
||||||
|
if ($iPos) {
|
||||||
|
$sKey = \substr($sPassword, 0, $iPos);
|
||||||
|
$sLogin = $_SERVER['REMOTE_USER'] . '/' . \substr($sPassword, 0, $iPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue