Skip to content

Commit be9bece

Browse files
authored
Merge pull request #527 from dkarlovi/rebase-1.6
Merge 1.6
2 parents c0382eb + a5db0dd commit be9bece

29 files changed

+3220
-115
lines changed

Controller/AuthorizeController.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use Symfony\Component\HttpFoundation\Response;
3030
use Symfony\Component\HttpFoundation\Session\SessionInterface;
3131
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
32-
use Symfony\Component\Routing\Router;
32+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
3333
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
3434
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
3535
use Symfony\Component\Security\Core\User\UserInterface;
@@ -86,7 +86,7 @@ class AuthorizeController implements ContainerAwareInterface
8686
private $tokenStorage;
8787

8888
/**
89-
* @var Router
89+
* @var UrlGeneratorInterface
9090
*/
9191
private $router;
9292

@@ -118,7 +118,7 @@ class AuthorizeController implements ContainerAwareInterface
118118
* @param OAuth2 $oAuth2Server
119119
* @param EngineInterface $templating
120120
* @param TokenStorageInterface $tokenStorage
121-
* @param Router $router
121+
* @param UrlGeneratorInterface $router
122122
* @param ClientManagerInterface $clientManager
123123
* @param EventDispatcher $eventDispatcher
124124
* @param string $templateEngineType
@@ -131,7 +131,7 @@ public function __construct(
131131
OAuth2 $oAuth2Server,
132132
EngineInterface $templating,
133133
TokenStorageInterface $tokenStorage,
134-
Router $router,
134+
UrlGeneratorInterface $router,
135135
ClientManagerInterface $clientManager,
136136
EventDispatcher $eventDispatcher,
137137
$templateEngineType = 'twig'
@@ -253,25 +253,23 @@ protected function getRedirectionUrl(UserInterface $user)
253253
*/
254254
protected function getClient()
255255
{
256-
if (null === $this->client) {
257-
$request = $this->getCurrentRequest();
256+
if (null !== $this->client) {
257+
return $this->client;
258+
}
258259

259-
$client = null;
260-
if (null !== $request) {
261-
if (null === $clientId = $request->get('client_id')) {
262-
$form = $this->authorizeForm;
263-
$formData = $request->get($form->getName(), []);
264-
$clientId = isset($formData['client_id']) ? $formData['client_id'] : null;
265-
}
260+
if (null === $request = $this->getCurrentRequest()) {
261+
throw new NotFoundHttpException('Client not found.');
262+
}
266263

267-
$client = $this->clientManager->findClientByPublicId($clientId);
268-
}
264+
if (null === $clientId = $request->get('client_id')) {
265+
$formData = $request->get($this->authorizeForm->getName(), []);
266+
$clientId = isset($formData['client_id']) ? $formData['client_id'] : null;
267+
}
269268

270-
if (null === $client) {
271-
throw new NotFoundHttpException('Client not found.');
272-
}
269+
$this->client = $this->clientManager->findClientByPublicId($clientId);
273270

274-
$this->client = $client;
271+
if (null === $this->client) {
272+
throw new NotFoundHttpException('Client not found.');
275273
}
276274

277275
return $this->client;

Entity/AuthCodeManager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
namespace FOS\OAuthServerBundle\Entity;
1515

16-
use Doctrine\ORM\EntityManager;
16+
use Doctrine\ORM\EntityManagerInterface;
1717
use FOS\OAuthServerBundle\Model\AuthCodeInterface;
1818
use FOS\OAuthServerBundle\Model\AuthCodeManager as BaseAuthCodeManager;
1919

2020
class AuthCodeManager extends BaseAuthCodeManager
2121
{
2222
/**
23-
* @var EntityManager
23+
* @var EntityManagerInterface
2424
*/
2525
protected $em;
2626

@@ -30,10 +30,10 @@ class AuthCodeManager extends BaseAuthCodeManager
3030
protected $class;
3131

3232
/**
33-
* @param EntityManager $em
34-
* @param string $class
33+
* @param EntityManagerInterface $em
34+
* @param string $class
3535
*/
36-
public function __construct(EntityManager $em, $class)
36+
public function __construct(EntityManagerInterface $em, $class)
3737
{
3838
$this->em = $em;
3939
$this->class = $class;

Form/Handler/AuthorizeFormHandler.php

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,34 @@ public function isRejected()
7373
return !$this->form->getData()->accepted;
7474
}
7575

76+
/**
77+
* @return bool
78+
*/
7679
public function process()
7780
{
7881
$request = $this->getCurrentRequest();
79-
if (null !== $request) {
80-
$this->form->setData(new Authorize(
81-
$request->request->has('accepted'),
82-
$request->query->all()
83-
));
84-
85-
if ('POST' === $request->getMethod()) {
86-
$this->form->handleRequest($request);
87-
if ($this->form->isValid()) {
88-
$this->onSuccess();
89-
90-
return true;
91-
}
92-
}
82+
83+
if (null === $request) {
84+
return false;
85+
}
86+
87+
$this->form->setData(new Authorize(
88+
$request->request->has('accepted'),
89+
$request->query->all()
90+
));
91+
92+
if ('POST' !== $request->getMethod()) {
93+
return false;
94+
}
95+
96+
$this->form->handleRequest($request);
97+
if (!$this->form->isValid()) {
98+
return false;
9399
}
94100

95-
return false;
101+
$this->onSuccess();
102+
103+
return true;
96104
}
97105

98106
public function getScope()
@@ -119,14 +127,14 @@ protected function onSuccess()
119127

120128
private function getCurrentRequest()
121129
{
122-
if (null !== $this->requestStack) {
123-
if ($this->requestStack instanceof Request) {
124-
return $this->requestStack;
125-
}
130+
if (null === $this->requestStack) {
131+
return $this->container->get('request');
132+
}
126133

127-
return $this->requestStack->getCurrentRequest();
134+
if ($this->requestStack instanceof Request) {
135+
return $this->requestStack;
128136
}
129137

130-
return $this->container->get('request');
138+
return $this->requestStack->getCurrentRequest();
131139
}
132140
}

0 commit comments

Comments
 (0)