From 09d357ed472d2193f9b2d1797452cda1256307a9 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 14 Nov 2013 19:23:56 -0800 Subject: baby steps tring to get magix auth working for redmtx --- mod/magic.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/magic.php b/mod/magic.php index 4eb688767..4794f86a8 100644 --- a/mod/magic.php +++ b/mod/magic.php @@ -33,12 +33,20 @@ function magic_init(&$a) { if(count($b) >= 2) { $u = $b[0] . '//' . $b[2]; -dbg(1); + $x = q("select xchan.xchan_url, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash - where hubloc_url = '%s' order by hubloc_id desc limit 1", + where hubloc_url = '%s' order by hubloc_id desc limit 5", dbesc($u) ); -dbg(0); + + if($x) { + // They must have a valid hubloc_addr + while(! strpos($x[0]['hubloc_addr'],'@')) { + array_shift($x); + } + } + + } } @@ -129,7 +137,10 @@ dbg(0); dbesc(datetime_convert()) ); - goaway($x[0]['hubloc_callback'] . '/' . substr($x[0]['hubloc_addr'],0,strpos($x[0]['hubloc_addr'],'@')) + $target_url = $x[0]['hubloc_callback'] . '/' . substr($x[0]['hubloc_addr'],0,strpos($x[0]['hubloc_addr'],'@')) ; + logger('mod_magic: redirecting to: ' . $target_url, LOGGER_DEBUG); + + goaway($target_url . '/?f=&auth=' . $channel['channel_address'] . '@' . $a->get_hostname() . '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION); } -- cgit v1.2.3