aboutsummaryrefslogtreecommitdiffstats
path: root/mod/magic.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-03-10 02:23:14 -0700
committerfriendica <info@friendica.com>2015-03-10 02:23:14 -0700
commit98dffd77efbad934a26fb4abee9b3e42eeb7b6d2 (patch)
treed2b486cd467ddd6436b33eec3e106e25af188630 /mod/magic.php
parent4237e8052e938d22cafd81dd2a37cf1bfd511fac (diff)
downloadvolse-hubzilla-98dffd77efbad934a26fb4abee9b3e42eeb7b6d2.tar.gz
volse-hubzilla-98dffd77efbad934a26fb4abee9b3e42eeb7b6d2.tar.bz2
volse-hubzilla-98dffd77efbad934a26fb4abee9b3e42eeb7b6d2.zip
channel delegation
Diffstat (limited to 'mod/magic.php')
-rw-r--r--mod/magic.php29
1 files changed, 27 insertions, 2 deletions
diff --git a/mod/magic.php b/mod/magic.php
index c31fa71ae..df8ac39a8 100644
--- a/mod/magic.php
+++ b/mod/magic.php
@@ -10,11 +10,10 @@ function magic_init(&$a) {
logger('mod_magic: args: ' . print_r($_REQUEST,true),LOGGER_DATA);
$addr = ((x($_REQUEST,'addr')) ? $_REQUEST['addr'] : '');
- $hash = ((x($_REQUEST,'hash')) ? $_REQUEST['hash'] : '');
$dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : '');
$test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0);
$rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0);
-
+ $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : '');
$parsed = parse_url($dest);
if(! $parsed) {
@@ -100,6 +99,29 @@ function magic_init(&$a) {
$ret['message'] .= 'Local site - you are already authenticated.' . EOL;
return $ret;
}
+
+ $delegation_success = false;
+ if($delegate) {
+ $r = q("select * from channel left join hubloc on channel_hash = hubloc_hash where hubloc_addr = '%s' limit 1",
+ dbesc($delegate)
+ );
+ if($r && intval($r[0]['channel_id'])) {
+ $allowed = perm_is_allowed($r[0]['channel_id'],get_observer_hash(),'delegate');
+ if($allowed) {
+ $_SESSION['delegate_channel'] = $r[0]['channel_id'];
+ $_SESSION['delegate'] = get_observer_hash();
+ $_SESSION['account_id'] = intval($r[0]['channel_account_id']);
+ change_channel($r[0]['channel_id']);
+ $delegation_success = true;
+ }
+ }
+ }
+
+
+
+ // FIXME: check and honour local delegation
+
+
goaway($dest);
}
@@ -123,6 +145,9 @@ function magic_init(&$a) {
$target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode($channel['channel_address'] . '@' . $a->get_hostname())
. '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION;
+ if($delegate)
+ $target_url .= '&delegate=' . urlencode($delegate);
+
logger('mod_magic: redirecting to: ' . $target_url, LOGGER_DEBUG);
if($test) {