X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FMagic.php;h=491ed31cbd4a4bd0c24036ea45a398325d078251;hb=3cd654e76f32dbcf505aef6a60a3e42d318f8b61;hp=01c5d5d464abf90ba0035a17b2a4f1da92ad8d1f;hpb=991f259ecb58720c0993718bc944bc60e83226b4;p=friendica.git diff --git a/src/Module/Magic.php b/src/Module/Magic.php index 01c5d5d464..491ed31cbd 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -28,10 +28,10 @@ class Magic extends BaseModule Logger::log('args: ' . print_r($_REQUEST, true), Logger::DATA); - $addr = ((x($_REQUEST, 'addr')) ? $_REQUEST['addr'] : ''); - $dest = ((x($_REQUEST, 'dest')) ? $_REQUEST['dest'] : ''); - $test = ((x($_REQUEST, 'test')) ? intval($_REQUEST['test']) : 0); - $owa = ((x($_REQUEST, 'owa')) ? intval($_REQUEST['owa']) : 0); + $addr = defaults($_REQUEST, 'addr', ''); + $dest = defaults($_REQUEST, 'dest', ''); + $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 @@ -43,14 +43,14 @@ class Magic extends BaseModule } if (!$cid) { - Logger::log('No contact record found: ' . print_r($_REQUEST, true), Logger::DEBUG); + Logger::log('No contact record found: ' . json_encode($_REQUEST), Logger::DEBUG); // @TODO Finding a more elegant possibility to redirect to either internal or external URL $a->redirect($dest); } $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); // Redirect if the contact is already authenticated on this site. - if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], normalise_link(self::getApp()->getBaseURL())) !== false) { + if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(self::getApp()->getBaseURL())) !== false) { if ($test) { $ret['success'] = true; $ret['message'] .= 'Local site - you are already authenticated.' . EOL; @@ -74,7 +74,7 @@ class Magic extends BaseModule $basepath = $exp[0]; $headers = []; - $headers['Accept'] = 'application/x-dfrn+json'; + $headers['Accept'] = 'application/x-dfrn+json, application/x-zot+json'; $headers['X-Open-Web-Auth'] = Strings::getRandomHex(); // Create a header that is signed with the local users private key. @@ -95,7 +95,7 @@ class Magic extends BaseModule if ($j['encrypted_token']) { // The token is encrypted. If the local user is really the one the other instance // thinks he/she is, the token can be decrypted with the local users public key. - openssl_private_decrypt(base64url_decode($j['encrypted_token']), $token, $user['prvkey']); + openssl_private_decrypt(Strings::base64UrlDecode($j['encrypted_token']), $token, $user['prvkey']); } else { $token = $j['token']; }