mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +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']) {
|
if ($aData && isset($aData['IsSet'], $aData['Enable']) && !empty($aData['Secret']) && $aData['IsSet'] && $aData['Enable']) {
|
||||||
$sCode = \trim($this->jsonParam('totp_code', ''));
|
$sCode = \trim($this->jsonParam('totp_code', ''));
|
||||||
if (empty($sCode)) {
|
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);
|
throw new ClientException(static::AccountTwoFactorAuthRequired);
|
||||||
} else {
|
}
|
||||||
$this->Logger()->Write('TFA: Verify Code for ' . $oAccount->ParentEmailHelper() . ' account.');
|
|
||||||
|
|
||||||
$bUseBackupCode = false;
|
$this->Logger()->Write("TFA: Verify Code for {$oAccount->ParentEmailHelper()} account.");
|
||||||
if (6 < \strlen($sCode) && !empty($aData['BackupCodes'])) {
|
$bUseBackupCode = false;
|
||||||
$aBackupCodes = \explode(' ', \trim(\preg_replace('/[^\d]+/', ' ', $aData['BackupCodes'])));
|
if (6 < \strlen($sCode) && !empty($aData['BackupCodes'])) {
|
||||||
$bUseBackupCode = \in_array($sCode, $aBackupCodes);
|
$aBackupCodes = \explode(' ', \trim(\preg_replace('/[^\d]+/', ' ', $aData['BackupCodes'])));
|
||||||
|
$bUseBackupCode = \in_array($sCode, $aBackupCodes);
|
||||||
if ($bUseBackupCode) {
|
if ($bUseBackupCode) {
|
||||||
$this->removeBackupCodeFromTwoFactorInfo($oAccount->ParentEmailHelper(), $sCode);
|
$this->removeBackupCodeFromTwoFactorInfo($oAccount->ParentEmailHelper(), $sCode);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$bUseBackupCode && !$this->TwoFactorAuthProvider($oAccount)->VerifyCode($aData['Secret'], $sCode)) {
|
if (!$bUseBackupCode && !$this->TwoFactorAuthProvider($oAccount)->VerifyCode($aData['Secret'], $sCode)) {
|
||||||
$this->Manager()->Actions()->loginErrorDelay();
|
$this->Manager()->Actions()->LoggerAuthHelper($oAccount);
|
||||||
|
throw new ClientException(static::AccountTwoFactorAuthError);
|
||||||
$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));
|
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();
|
return $this->Manager()->Actions()->Logger();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
|
const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
|
||||||
placeholder = 'LOGIN/LABEL_VERIFICATION_CODE';
|
placeholder = 'LOGIN/LABEL_VERIFICATION_CODE';
|
||||||
if (container) {
|
if (container) {
|
||||||
container.append(Element.fromHTML('<div class="controls">'
|
container.prepend(Element.fromHTML('<div class="controls">'
|
||||||
+ '<div class="input-append">'
|
+ '<div class="input-append">'
|
||||||
+ '<input name="totp_code" type="text" class="input-block-level inputIcon"'
|
+ '<input name="totp_code" type="text" class="input-block-level inputIcon"'
|
||||||
+ ' pattern="[0-9]*" inputmode="numeric"'
|
+ ' pattern="[0-9]*" inputmode="numeric"'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue