Attempt to fix sign me tokens #731 and #719

This commit is contained in:
the-djmaze 2022-12-01 23:00:00 +01:00
parent 4d0ee8736b
commit f2aba8b11d
3 changed files with 17 additions and 18 deletions

View file

@ -323,18 +323,20 @@ trait UserAuth
{
$sSignMeToken = Utils::GetCookie(self::AUTH_SIGN_ME_TOKEN_KEY);
if ($sSignMeToken) {
\SnappyMail\Log::notice(self::AUTH_SIGN_ME_TOKEN_KEY, 'decrypt');
$aResult = \SnappyMail\Crypt::DecryptUrlSafe($sSignMeToken);
if (isset($aResult['e'], $aResult['u']) && \SnappyMail\UUID::isValid($aResult['u'])) {
return $aResult;
}
\SnappyMail\Log::notice(self::AUTH_SIGN_ME_TOKEN_KEY, 'invalid');
Utils::ClearCookie(self::AUTH_SIGN_ME_TOKEN_KEY);
}
return null;
}
private function SetSignMeToken(MainAccount $oAccount): void
{
// $this->ClearSignMeData();
$this->ClearSignMeData();
$uuid = \SnappyMail\UUID::generate();
$data = \SnappyMail\Crypt::Encrypt($oAccount);
Utils::SetCookie(