20
20
use OAuth2 \OAuth2 ;
21
21
use OAuth2 \OAuth2ServerException ;
22
22
use Symfony \Bundle \FrameworkBundle \Templating \EngineInterface ;
23
- use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
24
- use Symfony \Component \DependencyInjection \ContainerInterface ;
25
23
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
26
24
use Symfony \Component \Form \Form ;
27
25
use Symfony \Component \HttpFoundation \Request ;
39
37
*
40
38
* @author Chris Jones <leeked@gmail.com>
41
39
*/
42
- class AuthorizeController implements ContainerAwareInterface
40
+ class AuthorizeController
43
41
{
44
- /**
45
- * @var ContainerInterface
46
- */
47
- protected $ container ;
48
42
/**
49
43
* @var ClientInterface
50
44
*/
@@ -107,12 +101,11 @@ class AuthorizeController implements ContainerAwareInterface
107
101
108
102
/**
109
103
* This controller had been made as a service due to support symfony 4 where all* services are private by default.
110
- * Thus, there is considered a bad practice to fetch services directly from container.
104
+ * Thus, this is considered a bad practice to fetch services directly from container.
111
105
*
112
- * @todo This controller could be refactored to do not rely on so many dependencies
106
+ * @todo This controller could be refactored to not rely on so many dependencies
113
107
*
114
108
* @param RequestStack $requestStack
115
- * @param SessionInterface $session
116
109
* @param Form $authorizeForm
117
110
* @param AuthorizeFormHandler $authorizeFormHandler
118
111
* @param OAuth2 $oAuth2Server
@@ -121,11 +114,11 @@ class AuthorizeController implements ContainerAwareInterface
121
114
* @param UrlGeneratorInterface $router
122
115
* @param ClientManagerInterface $clientManager
123
116
* @param EventDispatcherInterface $eventDispatcher
117
+ * @param SessionInterface $session
124
118
* @param string $templateEngineType
125
119
*/
126
120
public function __construct (
127
121
RequestStack $ requestStack ,
128
- SessionInterface $ session ,
129
122
Form $ authorizeForm ,
130
123
AuthorizeFormHandler $ authorizeFormHandler ,
131
124
OAuth2 $ oAuth2Server ,
@@ -134,6 +127,7 @@ public function __construct(
134
127
UrlGeneratorInterface $ router ,
135
128
ClientManagerInterface $ clientManager ,
136
129
EventDispatcherInterface $ eventDispatcher ,
130
+ SessionInterface $ session = null ,
137
131
$ templateEngineType = 'twig '
138
132
) {
139
133
$ this ->requestStack = $ requestStack ;
@@ -149,16 +143,6 @@ public function __construct(
149
143
$ this ->eventDispatcher = $ eventDispatcher ;
150
144
}
151
145
152
- /**
153
- * Sets the container.
154
- *
155
- * @param ContainerInterface|null $container A ContainerInterface instance or null
156
- */
157
- public function setContainer (ContainerInterface $ container = null )
158
- {
159
- $ this ->container = $ container ;
160
- }
161
-
162
146
/**
163
147
* Authorize.
164
148
*/
@@ -170,7 +154,7 @@ public function authorizeAction(Request $request)
170
154
throw new AccessDeniedException ('This user does not have access to this section. ' );
171
155
}
172
156
173
- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
157
+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
174
158
$ this ->session ->invalidate (600 );
175
159
$ this ->session ->set ('_fos_oauth_server.ensure_logout ' , true );
176
160
}
@@ -211,7 +195,7 @@ public function authorizeAction(Request $request)
211
195
*/
212
196
protected function processSuccess (UserInterface $ user , AuthorizeFormHandler $ formHandler , Request $ request )
213
197
{
214
- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
198
+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
215
199
$ this ->tokenStorage ->setToken (null );
216
200
$ this ->session ->invalidate ();
217
201
}
0 commit comments