Other solutions for nextcloud auto login #1247 due to a TOTP conflict

This commit is contained in:
the-djmaze 2023-10-02 15:51:19 +02:00
parent 31d50cf67e
commit 26b7abf893
6 changed files with 17 additions and 18 deletions

View file

@ -93,7 +93,7 @@ trait Accounts
}
if ($bNew || $sPassword) {
$oNewAccount = $this->LoginProcess($sEmail, $sPassword, false, false);
$oNewAccount = $this->LoginProcess($sEmail, $sPassword, false);
$aAccounts[$sEmail] = $oNewAccount->asTokenArray($oMainAccount);
} else {
$aAccounts[$sEmail] = \RainLoop\Model\AdditionalAccount::convertArray($aAccounts[$sEmail]);

View file

@ -36,18 +36,18 @@ trait User
{
$sEmail = \MailSo\Base\Utils::Trim($this->GetActionParam('Email', ''));
$sPassword = $this->GetActionParam('Password', '');
$bSignMe = !empty($this->GetActionParam('signMe', 0));
$this->logMask($sPassword);
try {
$oAccount = $this->LoginProcess($sEmail, $sPassword, $bSignMe);
$oAccount = $this->LoginProcess($sEmail, $sPassword);
} catch (\Throwable $oException) {
$this->loginErrorDelay();
throw $oException;
}
$this->SetAuthToken($oAccount);
empty($this->GetActionParam('signMe', 0)) || $this->SetSignMeToken($oAccount);
$this->Plugins()->RunHook('login.success', array($oAccount));

View file

@ -113,7 +113,7 @@ trait UserAuth
/**
* @throws \RainLoop\Exceptions\ClientException
*/
public function LoginProcess(string &$sEmail, string &$sPassword, bool $bSignMe = false, bool $bMainAccount = true): Account
public function LoginProcess(string &$sEmail, string &$sPassword, bool $bMainAccount = true): Account
{
$sInputEmail = $sEmail;
@ -139,14 +139,6 @@ trait UserAuth
$this->imapConnect($oAccount, true);
if ($bMainAccount) {
if($bSignMe){
// SetAuthToken token needs to be called before SetSignMeToken
// because $_COOKIE['smctoken'] is used by Crypt::Passphrase.
// If the $_COOKIE['smctoken'] is not set then SetSignMeToken
// throws an exception
$this->SetAuthToken($oAccount);
$this->SetSignMeToken($oAccount);
}
$this->StorageProvider()->Put($oAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
}
@ -334,8 +326,14 @@ trait UserAuth
return null;
}
private function SetSignMeToken(MainAccount $oAccount): void
public function SetSignMeToken(MainAccount $oAccount): void
{
// SetAuthToken token needs to be called first
// because $_COOKIE['smctoken'] is used by Crypt::Passphrase.
// If the $_COOKIE['smctoken'] is not set then SetSignMeToken
// throws an exception
// $this->SetAuthToken($oAccount);
$this->ClearSignMeData();
$uuid = \SnappyMail\UUID::generate();
$data = \SnappyMail\Crypt::Encrypt($oAccount);