Merge pull request #7674 from annando/fix-magic-again

Fix magic auth for redirects with non profile paths
This commit is contained in:
Tobias Diekershoff 2019-09-29 06:51:43 +02:00 committed by GitHub
commit 4d8ca5c9c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -192,7 +192,7 @@ function redir_magic($a, $cid, $url)
$serverret = Network::curl($basepath . '/magic'); $serverret = Network::curl($basepath . '/magic');
if ($serverret->isSuccess()) { if ($serverret->isSuccess()) {
$separator = strpos($target_url, '?') ? '&' : '?'; $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]); Logger::info('Redirecting with magic', ['target' => $target_url, 'visitor' => $visitor, 'contact' => $contact_url]);
$a->redirect($target_url); $a->redirect($target_url);

View File

@ -33,13 +33,10 @@ class Magic extends BaseModule
$test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0); $test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0);
$owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0); $owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0);
// NOTE: I guess $dest isn't just the profile url (could be also if (!empty($addr)) {
// 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)) {
$cid = Contact::getIdForURL($addr); $cid = Contact::getIdForURL($addr);
} else {
$cid = Contact::getIdForURL($dest);
} }
if (!$cid) { if (!$cid) {