mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-31 03:52:01 +08:00
Resolve #1241
This commit is contained in:
parent
26b7abf893
commit
edad4ac025
4 changed files with 11 additions and 10 deletions
|
@ -82,11 +82,11 @@ class SnappyMailHelper
|
|||
$oActions->Logger()->AddSecret($aCredentials[2]);
|
||||
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2]);
|
||||
if ($oAccount) {
|
||||
$oActions->Plugins()->RunHook('login.success', array($oAccount));
|
||||
$oActions->SetAuthToken($oAccount);
|
||||
if ($oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DEFAULT_OFF) === \RainLoop\Enumerations\SignMeType::DEFAULT_ON) {
|
||||
$oActions->SetSignMeToken($oAccount);
|
||||
}
|
||||
$oActions->Plugins()->RunHook('login.success', array($oAccount));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Login failure, reset password to prevent more attempts
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use \RainLoop\Exceptions\ClientException;
|
||||
use \RainLoop\Model\Account;
|
||||
use \RainLoop\Model\MainAccount;
|
||||
|
||||
class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
|
@ -20,7 +21,8 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$this->addJs('js/TwoFactorAuthLogin.js');
|
||||
$this->addJs('js/TwoFactorAuthSettings.js');
|
||||
|
||||
$this->addHook('login.success', 'DoLogin');
|
||||
// $this->addHook('login.success', 'DoLogin');
|
||||
$this->addHook('imap.after-login', 'DoLogin');
|
||||
$this->addHook('filter.app-data', 'FilterAppData');
|
||||
|
||||
$this->addJsonHook('GetTwoFactorInfo', 'DoGetTwoFactorInfo');
|
||||
|
@ -57,7 +59,8 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
}
|
||||
}
|
||||
|
||||
public function DoLogin(MainAccount $oAccount)
|
||||
// public function DoLogin(MainAccount $oAccount)
|
||||
public function DoLogin(Account $oAccount)
|
||||
{
|
||||
if ($this->TwoFactorAuthProvider($oAccount)) {
|
||||
$aData = $this->getTwoFactorInfo($oAccount);
|
||||
|
@ -240,10 +243,10 @@ class TwoFactorAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
return $this->Manager()->Actions()->StorageProvider();
|
||||
}
|
||||
|
||||
private $oTwoFactorAuthProvider;
|
||||
private $oTwoFactorAuthProvider = null;
|
||||
protected function TwoFactorAuthProvider(MainAccount $oAccount) : ?TwoFactorAuthInterface
|
||||
{
|
||||
if (!$this->oTwoFactorAuthProvider) {
|
||||
if (!$this->oTwoFactorAuthProvider && $oAccount instanceof MainAccount) {
|
||||
require __DIR__ . '/providers/interface.php';
|
||||
require __DIR__ . '/providers/totp.php';
|
||||
$this->oTwoFactorAuthProvider = new TwoFactorAuthTotp();
|
||||
|
|
|
@ -294,9 +294,6 @@ trait UserAuth
|
|||
{
|
||||
$this->oAdditionalAuthAccount = false;
|
||||
$this->oMainAuthAccount = $oAccount;
|
||||
if (!isset($_COOKIE['smctoken'])) {
|
||||
Cookies::set('smctoken', \base64_encode(\random_bytes(16)), 0, false);
|
||||
}
|
||||
static::SetAccountCookie(self::AUTH_SPEC_TOKEN_KEY, $oAccount);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,13 +41,14 @@ abstract class Crypt
|
|||
}
|
||||
|
||||
/**
|
||||
* When $key is empty, it will use a fingerprint of the user agent.
|
||||
* When $key is empty, it will use the smctoken.
|
||||
*/
|
||||
private static function Passphrase(?string $key) : string
|
||||
{
|
||||
if (!$key) {
|
||||
if (empty($_COOKIE['smctoken'])) {
|
||||
throw new \RuntimeException('Missing smctoken');
|
||||
\SnappyMail\Cookies::set('smctoken', \base64_encode(\random_bytes(16)), 0, false);
|
||||
// throw new \RuntimeException('Missing smctoken');
|
||||
}
|
||||
$key = $_COOKIE['smctoken'] . APP_VERSION;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue