Skip to content

Commit 1c47ce3

Browse files
Luis PabonGuilhemN
authored andcommitted
Handle cases in which Request is null
1 parent bf4ee32 commit 1c47ce3

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Controller/AuthorizeController.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,18 @@ protected function getClient()
152152
$request = $this->container->get('request');
153153
}
154154

155-
if (null === $clientId = $request->get('client_id')) {
156-
$form = $this->container->get('fos_oauth_server.authorize.form');
157-
$clientId = $request->get(sprintf('%s[client_id]', $form->getName()), null, true);
155+
$client = null;
156+
if (null !== $request) {
157+
if (null === $clientId = $request->get('client_id')) {
158+
$form = $this->container->get('fos_oauth_server.authorize.form');
159+
$clientId = $request->get(sprintf('%s[client_id]', $form->getName()), null, true);
160+
}
161+
162+
$client = $this->container
163+
->get('fos_oauth_server.client_manager')
164+
->findClientByPublicId($clientId);
158165
}
159166

160-
$client = $this->container
161-
->get('fos_oauth_server.client_manager')
162-
->findClientByPublicId($clientId);
163-
164167
if (null === $client) {
165168
throw new NotFoundHttpException('Client not found.');
166169
}

Form/Handler/AuthorizeFormHandler.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,19 @@ public function process()
6565
$request = $this->container->get('request');
6666
}
6767

68-
$this->form->setData(new Authorize(
69-
$request->request->has('accepted'),
70-
$request->query->all()
71-
));
72-
73-
if ('POST' === $request->getMethod()) {
74-
$this->form->handleRequest($request);
75-
if ($this->form->isValid()) {
76-
$this->onSuccess();
77-
78-
return true;
68+
if (null !== $request) {
69+
$this->form->setData(new Authorize(
70+
$request->request->has('accepted'),
71+
$request->query->all()
72+
));
73+
74+
if ('POST' === $request->getMethod()) {
75+
$this->form->handleRequest($request);
76+
if ($this->form->isValid()) {
77+
$this->onSuccess();
78+
79+
return true;
80+
}
7981
}
8082
}
8183

0 commit comments

Comments
 (0)