summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Coevoet <stof@notk.org>2011-06-06 21:38:57 +0200
committerChristophe Coevoet <stof@notk.org>2011-06-06 21:44:53 +0200
commitd39b5cc88441b4d0966f204a780fe1cb9663b6ab (patch)
tree04899e704d2a4593d1b648779adee992765bae9c
parent135e8126ffe15e4efc73def511e9fdefea69552d (diff)
downloadsymfony-security-d39b5cc88441b4d0966f204a780fe1cb9663b6ab.zip
symfony-security-d39b5cc88441b4d0966f204a780fe1cb9663b6ab.tar.gz
symfony-security-d39b5cc88441b4d0966f204a780fe1cb9663b6ab.tar.bz2
Added the support of the locale in the login path and the check path
-rw-r--r--Http/EntryPoint/FormAuthenticationEntryPoint.php5
-rw-r--r--Http/Firewall/AbstractAuthenticationListener.php12
2 files changed, 10 insertions, 7 deletions
diff --git a/Http/EntryPoint/FormAuthenticationEntryPoint.php b/Http/EntryPoint/FormAuthenticationEntryPoint.php
index 12f077f..057de2d 100644
--- a/Http/EntryPoint/FormAuthenticationEntryPoint.php
+++ b/Http/EntryPoint/FormAuthenticationEntryPoint.php
@@ -48,10 +48,11 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
*/
public function start(Request $request, AuthenticationException $authException = null)
{
+ $path = str_replace('{_locale}', $request->getSession()->getLocale(), $this->loginPath);
if ($this->useForward) {
- return $this->httpKernel->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
+ return $this->httpKernel->handle(Request::create($path), HttpKernelInterface::SUB_REQUEST);
}
- return new RedirectResponse(0 !== strpos($this->loginPath, 'http') ? $request->getUriForPath($this->loginPath) : $this->loginPath, 302);
+ return new RedirectResponse(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);
}
}
diff --git a/Http/Firewall/AbstractAuthenticationListener.php b/Http/Firewall/AbstractAuthenticationListener.php
index 1af25eb..441d120 100644
--- a/Http/Firewall/AbstractAuthenticationListener.php
+++ b/Http/Firewall/AbstractAuthenticationListener.php
@@ -166,7 +166,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
*/
protected function requiresAuthentication(Request $request)
{
- return $this->options['check_path'] === $request->getPathInfo();
+ return str_replace('{_locale}', $request->getSession()->getLocale(), $this->options['check_path']) === $request->getPathInfo();
}
/**
@@ -196,24 +196,26 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
$this->options['failure_path'] = $this->options['login_path'];
}
+ $path = str_replace('{_locale}', $request->getSession()->getLocale(), $this->options['failure_path']);
+
if ($this->options['failure_forward']) {
if (null !== $this->logger) {
- $this->logger->debug(sprintf('Forwarding to %s', $this->options['failure_path']));
+ $this->logger->debug(sprintf('Forwarding to %s', $path));
}
- $subRequest = Request::create($this->options['failure_path']);
+ $subRequest = Request::create($path);
$subRequest->attributes->set(SecurityContextInterface::AUTHENTICATION_ERROR, $failed);
return $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
if (null !== $this->logger) {
- $this->logger->debug(sprintf('Redirecting to %s', $this->options['failure_path']));
+ $this->logger->debug(sprintf('Redirecting to %s', $path));
}
$request->getSession()->set(SecurityContextInterface::AUTHENTICATION_ERROR, $failed);
- return new RedirectResponse(0 !== strpos($this->options['failure_path'], 'http') ? $request->getUriForPath($this->options['failure_path']) : $this->options['failure_path'], 302);
+ return new RedirectResponse(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);
}
private function onSuccess(GetResponseEvent $event, Request $request, TokenInterface $token)