Added failure_path_parameter to mirror target_path_parameter

This commit is contained in:
Leevi Graham 2012-10-29 18:23:42 +11:00 committed by Fabien Potencier
parent 9681973676
commit d0057d0e64
3 changed files with 10 additions and 3 deletions

View File

@ -43,6 +43,7 @@ abstract class AbstractFactory implements SecurityFactoryInterface
'failure_path' => null,
'failure_forward' => false,
'login_path' => '/login',
'failure_path_parameter' => '_failure_path',
);
public function create(ContainerBuilder $container, $id, $config, $userProviderId, $defaultEntryPointId)

View File

@ -33,6 +33,7 @@ security:
check_path: /login_check
default_target_path: /profile
target_path_parameter: "user_login[_target_path]"
failure_path_parameter: "user_login[_failure_path]"
username_parameter: "user_login[username]"
password_parameter: "user_login[password]"
csrf_parameter: "user_login[_token]"

View File

@ -50,9 +50,10 @@ class DefaultAuthenticationFailureHandler implements AuthenticationFailureHandle
$this->logger = $logger;
$this->options = array_merge(array(
'failure_path' => null,
'failure_forward' => false,
'login_path' => '/login',
'failure_path' => null,
'failure_forward' => false,
'login_path' => '/login',
'failure_path_parameter' => '_failure_path'
), $options);
}
@ -61,6 +62,10 @@ class DefaultAuthenticationFailureHandler implements AuthenticationFailureHandle
*/
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
if ($failureUrl = $request->get($this->options['failure_path_parameter'], null, true)) {
$this->options['failure_path'] = $failureUrl;
}
if (null === $this->options['failure_path']) {
$this->options['failure_path'] = $this->options['login_path'];
}