Protect against multiple accounts on different tabs #892

This commit is contained in:
the-djmaze 2023-01-30 22:42:37 +01:00
parent c21817e5e0
commit 3396a3d791
2 changed files with 6 additions and 2 deletions

View file

@ -14,7 +14,7 @@ class AdditionalAccount extends Account
public function Hash() : string
{
return \md5(parent::Hash() . $this->ParentEmail());
return \sha1(parent::Hash() . $this->ParentEmail());
}
public static function convertArray(array $aAccount) : array

View file

@ -74,12 +74,16 @@ class Utils
public static function GetConnectionToken() : string
{
$oActions = \RainLoop\Api::Actions();
$oAccount = $oActions->getAccountFromToken(false) ?: $oActions->getMainAccountFromToken(false);
if ($oAccount) {
return $oAccount->Hash();
}
$sToken = static::GetCookie(self::CONNECTION_TOKEN);
if (!$sToken) {
$sToken = \MailSo\Base\Utils::Sha1Rand(APP_SALT);
static::SetCookie(self::CONNECTION_TOKEN, $sToken, \time() + 3600 * 24 * 30);
}
return \sha1('Connection'.APP_SALT.$sToken.'Token'.APP_SALT);
}