mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 08:27:03 +03:00
parent
9a4b73e819
commit
1bf252ad7e
1 changed files with 8 additions and 11 deletions
|
|
@ -8,8 +8,8 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Two Factor Authentication',
|
NAME = 'Two Factor Authentication',
|
||||||
VERSION = '2.16.5',
|
VERSION = '2.16.6',
|
||||||
RELEASE = '2023-10-08',
|
RELEASE = '2023-10-24',
|
||||||
REQUIRED = '2.15.2',
|
REQUIRED = '2.15.2',
|
||||||
CATEGORY = 'Login',
|
CATEGORY = 'Login',
|
||||||
DESCRIPTION = 'Provides support for TOTP 2FA';
|
DESCRIPTION = 'Provides support for TOTP 2FA';
|
||||||
|
|
@ -21,8 +21,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
$this->addJs('js/TwoFactorAuthLogin.js');
|
$this->addJs('js/TwoFactorAuthLogin.js');
|
||||||
$this->addJs('js/TwoFactorAuthSettings.js');
|
$this->addJs('js/TwoFactorAuthSettings.js');
|
||||||
|
|
||||||
// $this->addHook('login.success', 'DoLogin');
|
$this->addHook('login.success', 'DoLogin');
|
||||||
$this->addHook('imap.after-login', 'AfterImapLogin');
|
|
||||||
$this->addHook('filter.app-data', 'FilterAppData');
|
$this->addHook('filter.app-data', 'FilterAppData');
|
||||||
|
|
||||||
$this->addJsonHook('GetTwoFactorInfo', 'DoGetTwoFactorInfo');
|
$this->addJsonHook('GetTwoFactorInfo', 'DoGetTwoFactorInfo');
|
||||||
|
|
@ -59,10 +58,9 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function DoLogin(MainAccount $oAccount)
|
public function DoLogin(MainAccount $oAccount)
|
||||||
public function AfterImapLogin(Account $oAccount, \MailSo\Imap\ImapClient $oImapClient, bool $bSuccess)
|
|
||||||
{
|
{
|
||||||
if ($bSuccess && $this->TwoFactorAuthProvider($oAccount)) {
|
if ($this->TwoFactorAuthProvider($oAccount)) {
|
||||||
$aData = $this->getTwoFactorInfo($oAccount);
|
$aData = $this->getTwoFactorInfo($oAccount);
|
||||||
if (isset($aData['IsSet'], $aData['Enable']) && !empty($aData['Secret']) && $aData['IsSet'] && $aData['Enable']) {
|
if (isset($aData['IsSet'], $aData['Enable']) && !empty($aData['Secret']) && $aData['IsSet'] && $aData['Enable']) {
|
||||||
$sCode = \trim($this->jsonParam('totp_code', ''));
|
$sCode = \trim($this->jsonParam('totp_code', ''));
|
||||||
|
|
@ -239,9 +237,9 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
private $oTwoFactorAuthProvider = null;
|
private $oTwoFactorAuthProvider = null;
|
||||||
protected function TwoFactorAuthProvider(Account $oAccount) : ?TwoFactorAuthInterface
|
protected function TwoFactorAuthProvider(MainAccount $oAccount) : ?TwoFactorAuthInterface
|
||||||
{
|
{
|
||||||
if (!$this->oTwoFactorAuthProvider && $oAccount instanceof MainAccount) {
|
if (!$this->oTwoFactorAuthProvider) {
|
||||||
require __DIR__ . '/providers/interface.php';
|
require __DIR__ . '/providers/interface.php';
|
||||||
require __DIR__ . '/providers/totp.php';
|
require __DIR__ . '/providers/totp.php';
|
||||||
$this->oTwoFactorAuthProvider = new TwoFactorAuthTotp();
|
$this->oTwoFactorAuthProvider = new TwoFactorAuthTotp();
|
||||||
|
|
@ -271,8 +269,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
'two_factor'
|
'two_factor'
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($sData)
|
if ($sData) {
|
||||||
{
|
|
||||||
$mData = static::DecodeKeyValues($sData);
|
$mData = static::DecodeKeyValues($sData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue