From 4e9a81020686fc63768e3a54bc1b2b8586e1aa0e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 Sep 2019 02:16:09 +0200 Subject: [PATCH] Fix magic auth for redirects with non profile paths --- mod/redir.php | 2 +- src/Module/Magic.php | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mod/redir.php b/mod/redir.php index 1df7060fa6..45e2791693 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -192,7 +192,7 @@ function redir_magic($a, $cid, $url) $serverret = Network::curl($basepath . '/magic'); if ($serverret->isSuccess()) { $separator = strpos($target_url, '?') ? '&' : '?'; - $target_url .= $separator . 'zrl=' . urlencode($visitor); + $target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url); Logger::info('Redirecting with magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]); $a->redirect($target_url); diff --git a/src/Module/Magic.php b/src/Module/Magic.php index 441fe7f157..4510d8d934 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -33,13 +33,10 @@ class Magic extends BaseModule $test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0); $owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0); - // NOTE: I guess $dest isn't just the profile url (could be also - // other profile pages e.g. photo). We need to find a solution - // to be able to redirct to other pages than the contact profile. - $cid = Contact::getIdForURL($dest); - - if (!$cid && !empty($addr)) { + if (!empty($addr)) { $cid = Contact::getIdForURL($addr); + } else { + $cid = Contact::getIdForURL($dest); } if (!$cid) { -- 2.39.5