Improved solution for #1241

This commit is contained in:
the-djmaze 2023-10-02 16:36:22 +02:00
parent edad4ac025
commit d4e76fb42c

View file

@ -22,7 +22,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
$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', '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');
@ -60,9 +60,9 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
} }
// public function DoLogin(MainAccount $oAccount) // public function DoLogin(MainAccount $oAccount)
public function DoLogin(Account $oAccount) public function AfterImapLogin(Account $oAccount, \MailSo\Imap\ImapClient $oImapClient, bool $bSuccess)
{ {
if ($this->TwoFactorAuthProvider($oAccount)) { if ($bSuccess && $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', ''));