Skip to content

Commit

Permalink
Added failure_path_parameter to mirror target_path_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
leevigraham authored and fabpot committed Dec 6, 2012
1 parent 9681973 commit d0057d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Expand Up @@ -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)
Expand Down
Expand Up @@ -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]"
Expand Down
Expand Up @@ -50,9 +50,10 @@ public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtil
$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);
}

Expand All @@ -61,6 +62,10 @@ public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtil
*/
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'];
}
Expand Down

0 comments on commit d0057d0

Please sign in to comment.