mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Bugfix: mailto handling was broken, and now also works without auto-login
This commit is contained in:
parent
a503329b77
commit
ee135f2032
5 changed files with 30 additions and 50 deletions
|
|
@ -317,25 +317,6 @@ class AppUser extends AbstractApp {
|
||||||
|
|
||||||
setTimeout(() => Remote.request('AppDelayStart'), 35000);
|
setTimeout(() => Remote.request('AppDelayStart'), 35000);
|
||||||
|
|
||||||
// When auto-login is active
|
|
||||||
if (
|
|
||||||
SettingsGet('AccountSignMe') &&
|
|
||||||
navigator.registerProtocolHandler
|
|
||||||
) {
|
|
||||||
setTimeout(() => {
|
|
||||||
try {
|
|
||||||
navigator.registerProtocolHandler(
|
|
||||||
'mailto',
|
|
||||||
location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s',
|
|
||||||
(SettingsGet('Title') || 'SnappyMail')
|
|
||||||
);
|
|
||||||
} catch (e) {} // eslint-disable-line no-empty
|
|
||||||
|
|
||||||
value = SettingsGet('MailToEmail');
|
|
||||||
value && mailToHelper(value);
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add pointermove ?
|
// add pointermove ?
|
||||||
addEventsListener(doc, ['touchstart','mousemove','keydown'], SettingsUserStore.delayLogout, {passive:true});
|
addEventsListener(doc, ['touchstart','mousemove','keydown'], SettingsUserStore.delayLogout, {passive:true});
|
||||||
SettingsUserStore.delayLogout();
|
SettingsUserStore.delayLogout();
|
||||||
|
|
@ -356,6 +337,21 @@ class AppUser extends AbstractApp {
|
||||||
setInterval(reloadTime(), 60000);
|
setInterval(reloadTime(), 60000);
|
||||||
|
|
||||||
PgpUserStore.init();
|
PgpUserStore.init();
|
||||||
|
|
||||||
|
// When auto-login is active
|
||||||
|
if (navigator.registerProtocolHandler) {
|
||||||
|
try {
|
||||||
|
navigator.registerProtocolHandler(
|
||||||
|
'mailto',
|
||||||
|
location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s',
|
||||||
|
(SettingsGet('Title') || 'SnappyMail')
|
||||||
|
);
|
||||||
|
} catch (e) {} // eslint-disable-line no-empty
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
value = SettingsGet('MailToEmail');
|
||||||
|
value && mailToHelper(value);
|
||||||
|
}, 500);
|
||||||
} else {
|
} else {
|
||||||
this.logout();
|
this.logout();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -818,16 +818,14 @@ class Actions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($aResult['AccountSignMe']) {
|
$sToken = Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null);
|
||||||
$sToken = Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null);
|
if (null !== $sToken) {
|
||||||
if (null !== $sToken) {
|
Utils::ClearCookie(self::AUTH_MAILTO_TOKEN_KEY);
|
||||||
Utils::ClearCookie(self::AUTH_MAILTO_TOKEN_KEY);
|
|
||||||
|
|
||||||
$mMailToData = Utils::DecodeKeyValuesQ($sToken);
|
$mMailToData = Utils::DecodeKeyValuesQ($sToken);
|
||||||
if (!empty($mMailToData['MailTo']) &&
|
if (!empty($mMailToData['MailTo']) &&
|
||||||
'MailTo' === $mMailToData['MailTo'] && !empty($mMailToData['To'])) {
|
'MailTo' === $mMailToData['MailTo'] && !empty($mMailToData['To'])) {
|
||||||
$aResult['MailToEmail'] = $mMailToData['To'];
|
$aResult['MailToEmail'] = $mMailToData['To'];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,18 +32,6 @@ trait User
|
||||||
return $this->oSuggestionsProvider;
|
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
|
* @throws \MailSo\Base\Exceptions\Exception
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ abstract class Service
|
||||||
$sResult = '';
|
$sResult = '';
|
||||||
if (\count($aPaths) && !empty($aPaths[0]) && 'index' !== \strtolower($aPaths[0]))
|
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);
|
\MailSo\Base\Http::StatusHeader(403);
|
||||||
echo $oServiceActions->ErrorTemplates('Access Denied.',
|
echo $oServiceActions->ErrorTemplates('Access Denied.',
|
||||||
"Disallowed Sec-Fetch
|
"Disallowed Sec-Fetch
|
||||||
|
|
|
||||||
|
|
@ -620,17 +620,15 @@ class ServiceActions
|
||||||
public function ServiceMailto() : string
|
public function ServiceMailto() : string
|
||||||
{
|
{
|
||||||
$this->oHttp->ServerNoCache();
|
$this->oHttp->ServerNoCache();
|
||||||
|
|
||||||
$sTo = \trim($_GET['to'] ?? '');
|
$sTo = \trim($_GET['to'] ?? '');
|
||||||
if (!empty($sTo) && \preg_match('/^mailto:/i', $sTo))
|
if (!empty($sTo) && \preg_match('/^mailto:/i', $sTo)) {
|
||||||
{
|
Utils::SetCookie(\RainLoop\Actions::AUTH_MAILTO_TOKEN_KEY,
|
||||||
$oAccount = $this->oActions->GetAccountFromSignMeToken();
|
Utils::EncodeKeyValuesQ(array(
|
||||||
if ($oAccount)
|
'Time' => \microtime(true),
|
||||||
{
|
'MailTo' => 'MailTo',
|
||||||
$this->oActions->SetMailtoRequest($sTo);
|
'To' => $sTo
|
||||||
}
|
)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->oActions->Location('./');
|
$this->oActions->Location('./');
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue