8000 Added failure_path_parameter to mirror target_path_parameter · symfony/symfony@d0057d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0057d0

Browse files
leevigrahamfabpot
authored andcommitted
Added failure_path_parameter to mirror target_path_parameter
1 parent 9681973 commit d0057d0

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ abstract class AbstractFactory implements SecurityFactoryInterface
4343
'failure_path' => null,
4444
'failure_forward' => false,
4545
'login_path' => '/login',
46+
'failure_path_parameter' => '_failure_path',
4647
);
4748

4849
public function create(ContainerBuilder $container, $id, $config, $userProviderId, $defaultEntryPointId)

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ security:
3333
check_path: /login_check
3434
default_target_path: /profile
3535
target_path_parameter: "user_login[_target_path]"
36+
failure_path_parameter: "user_login[_failure_path]"
3637
username_parameter: "user_login[username]"
3738
password_parameter: "user_login[password]"
3839
csrf_parameter: "user_login[_token]"

src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtil
5050
$this->logger = $logger;
5151

5252
$this->options = array_merge(array(
53-
'failure_path' => null,
54-
'failure_forward' => false,
55-
'login_path' => '/login',
53+
'failure_path' => null,
54+
'failure_forward' => false,
55+
'login_path' => '/login',
56+
'failure_path_parameter' => '_failure_path'
5657
), $options);
5758
}
5859

@@ -61,6 +62,10 @@ public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtil
6162
*/
6263
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
6364
{
65+
if ($failureUrl = $request->get($this->options['failure_path_parameter'], null, true)) {
66+
$this->options['failure_path'] = $failureUrl;
67+
}
68+
6469
if (null === $this->options['failure_path']) {
6570
$this->options['failure_path'] = $this->options['login_path'];
6671
}

0 commit comments

Comments
 (0)
0