mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-09 06:28:28 +03:00
Get this plugin working
This commit is contained in:
parent
2d1f99a8ce
commit
8b760ef0d1
2 changed files with 15 additions and 21 deletions
|
|
@ -44,29 +44,23 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
if ($aData && isset($aData['IsSet'], $aData['Enable']) && !empty($aData['Secret']) && $aData['IsSet'] && $aData['Enable']) {
|
||||
$sCode = \trim($this->jsonParam('totp_code', ''));
|
||||
if (empty($sCode)) {
|
||||
$this->Logger()->Write('TFA: Required Code for ' . $oAccount->ParentEmailHelper() . ' account.');
|
||||
|
||||
$this->Logger()->Write("TFA: Required Code for {$oAccount->ParentEmailHelper()} account.");
|
||||
throw new ClientException(static::AccountTwoFactorAuthRequired);
|
||||
} else {
|
||||
$this->Logger()->Write('TFA: Verify Code for ' . $oAccount->ParentEmailHelper() . ' account.');
|
||||
}
|
||||
|
||||
$bUseBackupCode = false;
|
||||
if (6 < \strlen($sCode) && !empty($aData['BackupCodes'])) {
|
||||
$aBackupCodes = \explode(' ', \trim(\preg_replace('/[^\d]+/', ' ', $aData['BackupCodes'])));
|
||||
$bUseBackupCode = \in_array($sCode, $aBackupCodes);
|
||||
|
||||
if ($bUseBackupCode) {
|
||||
$this->removeBackupCodeFromTwoFactorInfo($oAccount->ParentEmailHelper(), $sCode);
|
||||
}
|
||||
$this->Logger()->Write("TFA: Verify Code for {$oAccount->ParentEmailHelper()} account.");
|
||||
$bUseBackupCode = false;
|
||||
if (6 < \strlen($sCode) && !empty($aData['BackupCodes'])) {
|
||||
$aBackupCodes = \explode(' ', \trim(\preg_replace('/[^\d]+/', ' ', $aData['BackupCodes'])));
|
||||
$bUseBackupCode = \in_array($sCode, $aBackupCodes);
|
||||
if ($bUseBackupCode) {
|
||||
$this->removeBackupCodeFromTwoFactorInfo($oAccount->ParentEmailHelper(), $sCode);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bUseBackupCode && !$this->TwoFactorAuthProvider($oAccount)->VerifyCode($aData['Secret'], $sCode)) {
|
||||
$this->Manager()->Actions()->loginErrorDelay();
|
||||
|
||||
$this->Manager()->Actions()->LoggerAuthHelper($oAccount);
|
||||
|
||||
throw new ClientException(static::AccountTwoFactorAuthError);
|
||||
}
|
||||
if (!$bUseBackupCode && !$this->TwoFactorAuthProvider($oAccount)->VerifyCode($aData['Secret'], $sCode)) {
|
||||
$this->Manager()->Actions()->LoggerAuthHelper($oAccount);
|
||||
throw new ClientException(static::AccountTwoFactorAuthError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -207,7 +201,7 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
return $this->jsonResponse(__FUNCTION__, $this->getTwoFactorInfo($oAccount, true));
|
||||
}
|
||||
|
||||
protected function Logger() : \RainLoop\Providers\TwoFactorAuth
|
||||
protected function Logger() : \MailSo\Log\Logger
|
||||
{
|
||||
return $this->Manager()->Actions()->Logger();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
|
||||
placeholder = 'LOGIN/LABEL_VERIFICATION_CODE';
|
||||
if (container) {
|
||||
container.append(Element.fromHTML('<div class="controls">'
|
||||
container.prepend(Element.fromHTML('<div class="controls">'
|
||||
+ '<div class="input-append">'
|
||||
+ '<input name="totp_code" type="text" class="input-block-level inputIcon"'
|
||||
+ ' pattern="[0-9]*" inputmode="numeric"'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue