Skip to content

Commit

Permalink
Adjust renderFinishAuthorizationUri to Flow 6
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlemke committed May 13, 2020
1 parent 1d608d8 commit ee2ccbb
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Classes/OAuthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\ORM\ORMException;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Uri;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
Expand All @@ -17,13 +18,13 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Http\HttpRequestHandlerInterface;
use Neos\Flow\Http\Request;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
use Neos\Flow\Mvc\Routing\UriBuilder;
use Neos\Flow\Persistence\Doctrine\Query;
use Neos\Flow\Persistence\Exception\InvalidQueryException;
use Neos\Flow\Session\SessionInterface;
use Neos\Http\Factories\ServerRequestFactory;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UriInterface;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -57,6 +58,12 @@ abstract class OAuthClient
*/
protected $bootstrap;

/**
* @Flow\Inject
* @var ServerRequestFactory
*/
protected $serverRequestFactory;

/**
* @Flow\InjectConfiguration(path="http.baseUri", package="Neos.Flow")
* @var string
Expand Down Expand Up @@ -426,13 +433,12 @@ public function renderFinishAuthorizationUri(): string
{
$currentRequestHandler = $this->bootstrap->getActiveRequestHandler();
if ($currentRequestHandler instanceof HttpRequestHandlerInterface) {
$httpRequest = $currentRequestHandler->getHttpRequest();
$httpRequest = $currentRequestHandler->getComponentContext()->getHttpRequest();
} else {
putenv('FLOW_REWRITEURLS=1');
$httpRequest = Request::createFromEnvironment();
$httpRequest->setBaseUri(new Uri($this->flowBaseUriSetting));
$httpRequest = $this->serverRequestFactory->createServerRequest('GET', new Uri($this->flowBaseUriSetting));
}
$actionRequest = new ActionRequest($httpRequest);
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);

$this->uriBuilder->reset();
$this->uriBuilder->setRequest($actionRequest);
Expand Down

0 comments on commit ee2ccbb

Please sign in to comment.