local_user(), 'xchan' => $x[0], 'destination' => $dest, 'proceed' => true ); call_hooks('magic_auth',$arr); $dest = $arr['destination']; if(! $arr['proceed']) goaway($dest); if((get_observer_hash()) && ($x[0]['hubloc_url'] === z_root())) { // We are already authenticated on this site and a registered observer. // Just redirect. goaway($dest); } if(local_user()) { $channel = $a->get_channel(); $token = random_string(); $token_sig = base64url_encode(rsa_sign($token,$channel['channel_prvkey'])); $channel['token'] = $token; $channel['token_sig'] = $token_sig; $r = q("insert into verify ( type, channel, token, meta, created) values ('%s','%d','%s','%s','%s')", dbesc('auth'), intval($channel['channel_id']), dbesc($token), dbesc($x[0]['hubloc_url']), dbesc(datetime_convert()) ); $target_url = $x[0]['hubloc_callback']; logger('mod_magic: redirecting to: ' . $target_url, LOGGER_DEBUG); goaway($target_url . '/?f=&auth=' . urlencode($channel['channel_address'] . '@' . $a->get_hostname()) . '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION); } goaway($dest); }