Merge remote branch 'stof/security_login'
* stof/security_login: Added the support of the locale in the login path and the check path
This commit is contained in:
commit
882a8e3f09
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user