2323use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
2424use Symfony \Component \DependencyInjection \ContainerInterface ;
2525use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
26+ use Symfony \Bundle \FrameworkBundle \Templating \EngineInterface ;
27+ use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
2628use Symfony \Component \Form \Form ;
2729use Symfony \Component \HttpFoundation \Request ;
2830use Symfony \Component \HttpFoundation \RequestStack ;
3941 *
4042 * @author Chris Jones <leeked@gmail.com>
4143 */
42- class AuthorizeController implements ContainerAwareInterface
44+ class AuthorizeController
4345{
4446 /**
4547 * @var ContainerInterface
@@ -107,25 +109,23 @@ class AuthorizeController implements ContainerAwareInterface
107109
108110 /**
109111 * 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.
112+ * Thus, this is considered a bad practice to fetch services directly from container.
111113 *
112- * @todo This controller could be refactored to do not rely on so many dependencies
114+ * @todo This controller could be refactored to not rely on so many dependencies
113115 *
114- * @param RequestStack $requestStack
115- * @param SessionInterface $session
116- * @param Form $authorizeForm
117- * @param AuthorizeFormHandler $authorizeFormHandler
118- * @param OAuth2 $oAuth2Server
119- * @param EngineInterface $templating
120- * @param TokenStorageInterface $tokenStorage
121- * @param UrlGeneratorInterface $router
122- * @param ClientManagerInterface $clientManager
123- * @param EventDispatcherInterface $eventDispatcher
124- * @param string $templateEngineType
116+ * @param RequestStack $requestStack
117+ * @param Form $authorizeForm
118+ * @param AuthorizeFormHandler $authorizeFormHandler
119+ * @param OAuth2 $oAuth2Server
120+ * @param EngineInterface $templating
121+ * @param TokenStorageInterface $tokenStorage
122+ * @param UrlGeneratorInterface $router
123+ * @param ClientManagerInterface $clientManager
124+ * @param EventDispatcherInterface $eventDispatcher* @param SessionInterface $session
125+ * @param string $templateEngineType
125126 */
126127 public function __construct (
127128 RequestStack $ requestStack ,
128- SessionInterface $ session ,
129129 Form $ authorizeForm ,
130130 AuthorizeFormHandler $ authorizeFormHandler ,
131131 OAuth2 $ oAuth2Server ,
@@ -134,6 +134,7 @@ public function __construct(
134134 UrlGeneratorInterface $ router ,
135135 ClientManagerInterface $ clientManager ,
136136 EventDispatcherInterface $ eventDispatcher ,
137+ SessionInterface $ session = null ,
137138 $ templateEngineType = 'twig '
138139 ) {
139140 $ this ->requestStack = $ requestStack ;
@@ -170,7 +171,7 @@ public function authorizeAction(Request $request)
170171 throw new AccessDeniedException ('This user does not have access to this section. ' );
171172 }
172173
173- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
174+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
174175 $ this ->session ->invalidate (600 );
175176 $ this ->session ->set ('_fos_oauth_server.ensure_logout ' , true );
176177 }
@@ -211,7 +212,7 @@ public function authorizeAction(Request $request)
211212 */
212213 protected function processSuccess (UserInterface $ user , AuthorizeFormHandler $ formHandler , Request $ request )
213214 {
214- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
215+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
215216 $ this ->tokenStorage ->setToken (null );
216217 $ this ->session ->invalidate ();
217218 }
0 commit comments