2020use OAuth2 \OAuth2 ;
2121use OAuth2 \OAuth2ServerException ;
2222use Symfony \Bundle \FrameworkBundle \Templating \EngineInterface ;
23- use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
24- use Symfony \Component \DependencyInjection \ContainerInterface ;
2523use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
2624use Symfony \Component \Form \Form ;
2725use Symfony \Component \HttpFoundation \Request ;
3937 *
4038 * @author Chris Jones <[email protected] > 4139 */
42- class AuthorizeController implements ContainerAwareInterface
40+ class AuthorizeController
4341{
44- /**
45- * @var ContainerInterface
46- */
47- protected $ container ;
4842 /**
4943 * @var ClientInterface
5044 */
@@ -107,12 +101,11 @@ class AuthorizeController implements ContainerAwareInterface
107101
108102 /**
109103 * 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.
111105 *
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
113107 *
114108 * @param RequestStack $requestStack
115- * @param SessionInterface $session
116109 * @param Form $authorizeForm
117110 * @param AuthorizeFormHandler $authorizeFormHandler
118111 * @param OAuth2 $oAuth2Server
@@ -121,11 +114,11 @@ class AuthorizeController implements ContainerAwareInterface
121114 * @param UrlGeneratorInterface $router
122115 * @param ClientManagerInterface $clientManager
123116 * @param EventDispatcherInterface $eventDispatcher
117+ * @param SessionInterface $session
124118 * @param string $templateEngineType
125119 */
126120 public function __construct (
127121 RequestStack $ requestStack ,
128- SessionInterface $ session ,
129122 Form $ authorizeForm ,
130123 AuthorizeFormHandler $ authorizeFormHandler ,
131124 OAuth2 $ oAuth2Server ,
@@ -134,6 +127,7 @@ public function __construct(
134127 UrlGeneratorInterface $ router ,
135128 ClientManagerInterface $ clientManager ,
136129 EventDispatcherInterface $ eventDispatcher ,
130+ SessionInterface $ session = null ,
137131 $ templateEngineType = 'twig '
138132 ) {
139133 $ this ->requestStack = $ requestStack ;
@@ -149,16 +143,6 @@ public function __construct(
149143 $ this ->eventDispatcher = $ eventDispatcher ;
150144 }
151145
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-
162146 /**
163147 * Authorize.
164148 */
@@ -170,7 +154,7 @@ public function authorizeAction(Request $request)
170154 throw new AccessDeniedException ('This user does not have access to this section. ' );
171155 }
172156
173- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
157+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
174158 $ this ->session ->invalidate (600 );
175159 $ this ->session ->set ('_fos_oauth_server.ensure_logout ' , true );
176160 }
@@ -211,7 +195,7 @@ public function authorizeAction(Request $request)
211195 */
212196 protected function processSuccess (UserInterface $ user , AuthorizeFormHandler $ formHandler , Request $ request )
213197 {
214- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
198+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
215199 $ this ->tokenStorage ->setToken (null );
216200 $ this ->session ->invalidate ();
217201 }
0 commit comments