Bugfix: mailto handling was broken, and now also works without auto-login

This commit is contained in:
the-djmaze 2022-03-04 15:22:37 +01:00
parent a503329b77
commit ee135f2032
5 changed files with 30 additions and 50 deletions

View file

@ -818,16 +818,14 @@ class Actions
}
}
if ($aResult['AccountSignMe']) {
$sToken = Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null);
if (null !== $sToken) {
Utils::ClearCookie(self::AUTH_MAILTO_TOKEN_KEY);
$sToken = Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null);
if (null !== $sToken) {
Utils::ClearCookie(self::AUTH_MAILTO_TOKEN_KEY);
$mMailToData = Utils::DecodeKeyValuesQ($sToken);
if (!empty($mMailToData['MailTo']) &&
'MailTo' === $mMailToData['MailTo'] && !empty($mMailToData['To'])) {
$aResult['MailToEmail'] = $mMailToData['To'];
}
$mMailToData = Utils::DecodeKeyValuesQ($sToken);
if (!empty($mMailToData['MailTo']) &&
'MailTo' === $mMailToData['MailTo'] && !empty($mMailToData['To'])) {
$aResult['MailToEmail'] = $mMailToData['To'];
}
}

View file

@ -32,18 +32,6 @@ trait User
return $this->oSuggestionsProvider;
}
public function SetMailtoRequest(string $sTo): void
{
if (!empty($sTo)) {
Utils::SetCookie(self::AUTH_MAILTO_TOKEN_KEY,
Utils::EncodeKeyValuesQ(array(
'Time' => \microtime(true),
'MailTo' => 'MailTo',
'To' => $sTo
)), 0);
}
}
/**
* @throws \MailSo\Base\Exceptions\Exception
*/

View file

@ -112,7 +112,7 @@ abstract class Service
$sResult = '';
if (\count($aPaths) && !empty($aPaths[0]) && 'index' !== \strtolower($aPaths[0]))
{
if (!\SnappyMail\HTTP\SecFetch::isSameOrigin()) {
if ('mailto' !== \strtolower($aPaths[0]) && !\SnappyMail\HTTP\SecFetch::isSameOrigin()) {
\MailSo\Base\Http::StatusHeader(403);
echo $oServiceActions->ErrorTemplates('Access Denied.',
"Disallowed Sec-Fetch

View file

@ -620,17 +620,15 @@ class ServiceActions
public function ServiceMailto() : string
{
$this->oHttp->ServerNoCache();
$sTo = \trim($_GET['to'] ?? '');
if (!empty($sTo) && \preg_match('/^mailto:/i', $sTo))
{
$oAccount = $this->oActions->GetAccountFromSignMeToken();
if ($oAccount)
{
$this->oActions->SetMailtoRequest($sTo);
}
if (!empty($sTo) && \preg_match('/^mailto:/i', $sTo)) {
Utils::SetCookie(\RainLoop\Actions::AUTH_MAILTO_TOKEN_KEY,
Utils::EncodeKeyValuesQ(array(
'Time' => \microtime(true),
'MailTo' => 'MailTo',
'To' => $sTo
)), 0);
}
$this->oActions->Location('./');
return '';
}