mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Improve solution for #1241
This commit is contained in:
parent
0064a44031
commit
bd737a82bf
4 changed files with 22 additions and 28 deletions
|
|
@ -82,11 +82,14 @@ class SnappyMailHelper
|
||||||
$oActions->Logger()->AddSecret($aCredentials[2]);
|
$oActions->Logger()->AddSecret($aCredentials[2]);
|
||||||
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2]);
|
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2]);
|
||||||
if ($oAccount) {
|
if ($oAccount) {
|
||||||
|
// Must be here due to bug #1241
|
||||||
|
$oActions->SetMainAuthAccount($oAccount);
|
||||||
|
$oActions->Plugins()->RunHook('login.success', array($oAccount));
|
||||||
|
|
||||||
$oActions->SetAuthToken($oAccount);
|
$oActions->SetAuthToken($oAccount);
|
||||||
if ($oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DEFAULT_OFF) === \RainLoop\Enumerations\SignMeType::DEFAULT_ON) {
|
if ($oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DEFAULT_OFF) === \RainLoop\Enumerations\SignMeType::DEFAULT_ON) {
|
||||||
$oActions->SetSignMeToken($oAccount);
|
$oActions->SetSignMeToken($oAccount);
|
||||||
}
|
}
|
||||||
$oActions->Plugins()->RunHook('login.success', array($oAccount));
|
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
// Login failure, reset password to prevent more attempts
|
// Login failure, reset password to prevent more attempts
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use RainLoop\Model\MainAccount;
|
||||||
|
|
||||||
class ProxyauthLoginExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
class ProxyauthLoginExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Proxy Auth Login Example',
|
NAME = 'Proxy Auth Login Example',
|
||||||
VERSION = '2.2',
|
VERSION = '2.2',
|
||||||
RELEASE = '2022-12-08',
|
RELEASE = '2023-10-24',
|
||||||
REQUIRED = '2.23.0',
|
REQUIRED = '2.23.0',
|
||||||
CATEGORY = 'General',
|
CATEGORY = 'General',
|
||||||
DESCRIPTION = '';
|
DESCRIPTION = '';
|
||||||
|
|
@ -27,32 +29,15 @@ class ProxyauthLoginExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
/**
|
/**
|
||||||
* @param \RainLoop\Model\Account $oAccount
|
* @param \RainLoop\Model\Account $oAccount
|
||||||
*/
|
*/
|
||||||
public function EventLoginPostLoginProvide(&$oAccount)
|
public function EventLoginPostLoginProvide(MainAccount $oAccount)
|
||||||
{
|
{
|
||||||
if ($oAccount instanceof \RainLoop\Model\Account)
|
// Verify logic
|
||||||
{
|
if (!$this->isValidAccount($oAccount->IncLogin(), $oAccount->IncPassword())) {
|
||||||
// Verify logic
|
// throw a Auth Error Exception
|
||||||
$bValid = $this->isValidAccount($oAccount->IncLogin(), $oAccount->IncPassword());
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
|
||||||
|
|
||||||
/**
|
|
||||||
* $oAccount->Email(); // Email (It is not a IMAP login)
|
|
||||||
* $oAccount->IncLogin(); // IMAP login
|
|
||||||
* $oAccount->IncPassword(); // IMAP password
|
|
||||||
* $oAccount->Domain()->IncHost(); // IMAP host
|
|
||||||
*
|
|
||||||
* @see \RainLoo\Model\Account for more
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!$bValid) // if verify failed
|
|
||||||
{
|
|
||||||
// throw a Auth Error Exception
|
|
||||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
|
|
||||||
}
|
|
||||||
else // Or setup your proxyauth admin account credentials
|
|
||||||
{
|
|
||||||
$oAccount->SetProxyAuthUser('admin@domain.com');
|
|
||||||
$oAccount->SetProxyAuthPassword('secret-admin-password');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$oAccount->SetProxyAuthUser('admin@domain.com');
|
||||||
|
$oAccount->SetProxyAuthPassword('secret-admin-password');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ trait User
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be here due to bug #1241
|
// Must be here due to bug #1241
|
||||||
|
$this->SetMainAuthAccount($oAccount);
|
||||||
$this->Plugins()->RunHook('login.success', array($oAccount));
|
$this->Plugins()->RunHook('login.success', array($oAccount));
|
||||||
|
|
||||||
$this->SetAuthToken($oAccount);
|
$this->SetAuthToken($oAccount);
|
||||||
|
|
|
||||||
|
|
@ -290,10 +290,15 @@ trait UserAuth
|
||||||
return $this->oMainAuthAccount;
|
return $this->oMainAuthAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetAuthToken(MainAccount $oAccount): void
|
public function SetMainAuthAccount(MainAccount $oAccount): void
|
||||||
{
|
{
|
||||||
$this->oAdditionalAuthAccount = false;
|
$this->oAdditionalAuthAccount = false;
|
||||||
$this->oMainAuthAccount = $oAccount;
|
$this->oMainAuthAccount = $oAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function SetAuthToken(MainAccount $oAccount): void
|
||||||
|
{
|
||||||
|
$this->SetMainAuthAccount($oAccount);
|
||||||
static::SetAccountCookie(self::AUTH_SPEC_TOKEN_KEY, $oAccount);
|
static::SetAccountCookie(self::AUTH_SPEC_TOKEN_KEY, $oAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue