X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FMagic.php;h=1012dc72baffdbb57fddcb6e69b2ae50e32b7e19;hb=493e4ed9fb24ab82632e0aac1214c33362e793b4;hp=c47a7a4d504dffce50bf9e1acd7647692c8accf3;hpb=23c56b108b43bd1964d78993fb7a164b09fc30f1;p=friendica.git diff --git a/src/Module/Magic.php b/src/Module/Magic.php index c47a7a4d50..1012dc72ba 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -1,6 +1,6 @@ app = $app; - $this->logger = $logger; - $this->dba = $dba; - $this->httpClient = $httpClient; - $this->baseUrl = $baseUrl; + $this->app = $app; + $this->dba = $dba; + $this->httpClient = $httpClient; + $this->userSession = $userSession; } - public function rawContent() + protected function rawContent(array $request = []) { $this->logger->info('magic module: invoked'); @@ -87,14 +88,14 @@ class Magic extends BaseModule $contact = $this->dba->selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); // Redirect if the contact is already authenticated on this site. - if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl->get())) !== false) { + if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl)) !== false) { $this->logger->info('Contact is already authenticated'); System::externalRedirect($dest); } // OpenWebAuth - if (local_user() && $owa) { - $user = User::getById(local_user()); + if ($this->userSession->getLocalUserId() && $owa) { + $user = User::getById($this->userSession->getLocalUserId()); // Extract the basepath // NOTE: we need another solution because this does only work @@ -112,11 +113,11 @@ class Magic extends BaseModule $header = HTTPSignature::createSig( $header, $user['prvkey'], - 'acct:' . $user['nickname'] . '@' . $this->baseUrl->getHostname() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : '') + 'acct:' . $user['nickname'] . '@' . $this->baseUrl->getHost() . ($this->baseUrl->getPath() ? '/' . $this->baseUrl->getPath() : '') ); // Try to get an authentication token from the other instance. - $curlResult = $this->httpClient->get($basepath . '/owa', [HttpClientOptions::HEADERS => $header]); + $curlResult = $this->httpClient->get($basepath . '/owa', HttpClientAccept::DEFAULT, [HttpClientOptions::HEADERS => $header]); if ($curlResult->isSuccess()) { $j = json_decode($curlResult->getBody(), true);