@@ -166,7 +166,7 @@ public final function handle(GetResponseEvent $event)
166
166
*/
167
167
protected function requiresAuthentication (Request $ request )
168
168
{
169
- return $ this ->options ['check_path ' ] === $ request ->getPathInfo ();
169
+ return str_replace ( ' {_locale} ' , $ request -> getSession ()-> getLocale (), $ this ->options ['check_path ' ]) === $ request ->getPathInfo ();
170
170
}
171
171
172
172
/**
@@ -196,24 +196,26 @@ private function onFailure(GetResponseEvent $event, Request $request, Authentica
196
196
$ this ->options ['failure_path ' ] = $ this ->options ['login_path ' ];
197
197
}
198
198
199
+ $ path = str_replace ('{_locale} ' , $ request ->getSession ()->getLocale (), $ this ->options ['failure_path ' ]);
200
+
199
201
if ($ this ->options ['failure_forward ' ]) {
200
202
if (null !== $ this ->logger ) {
201
- $ this ->logger ->debug (sprintf ('Forwarding to %s ' , $ this -> options [ ' failure_path ' ] ));
203
+ $ this ->logger ->debug (sprintf ('Forwarding to %s ' , $ path ));
202
204
}
203
205
204
- $ subRequest = Request::create ($ this -> options [ ' failure_path ' ] );
206
+ $ subRequest = Request::create ($ path );
205
207
$ subRequest ->attributes ->set (SecurityContextInterface::AUTHENTICATION_ERROR , $ failed );
206
208
207
209
return $ event ->getKernel ()->handle ($ subRequest , HttpKernelInterface::SUB_REQUEST );
208
210
}
209
211
210
212
if (null !== $ this ->logger ) {
211
- $ this ->logger ->debug (sprintf ('Redirecting to %s ' , $ this -> options [ ' failure_path ' ] ));
213
+ $ this ->logger ->debug (sprintf ('Redirecting to %s ' , $ path ));
212
214
}
213
215
214
216
$ request ->getSession ()->set (SecurityContextInterface::AUTHENTICATION_ERROR , $ failed );
215
217
216
- return new RedirectResponse (0 !== strpos ($ this -> options [ ' failure_path ' ] , 'http ' ) ? $ request ->getUriForPath ($ this -> options [ ' failure_path ' ] ) : $ this -> options [ ' failure_path ' ] , 302 );
218
+ return new RedirectResponse (0 !== strpos ($ path , 'http ' ) ? $ request ->getUriForPath ($ path ) : $ path , 302 );
217
219
}
218
220
219
221
private function onSuccess (GetResponseEvent $ event , Request $ request , TokenInterface $ token )
0 commit comments