Skip to content

Commit 866f01a

Browse files
committed
feature #578 Move login route to const (JakubSzczesniak)
This PR was merged into the 1.0-dev branch. Discussion ---------- Move login route to const To eliminate long debug time and bug fixing in case of change login route. Connected with symfony/symfony-docs#13363 Commits ------- 9ce6179 Move login route to const
2 parents d1309e7 + 9ce6179 commit 866f01a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class <?= $class_name; ?> extends AbstractFormLoginAuthenticator<?= $password_au
2424
{
2525
use TargetPathTrait;
2626

27+
public const LOGIN_ROUTE = 'app_login';
28+
2729
<?= $user_is_entity ? " private \$entityManager;\n" : null ?>
2830
private $urlGenerator;
2931
private $csrfTokenManager;
@@ -39,7 +41,7 @@ public function __construct(<?= $user_is_entity ? 'EntityManagerInterface $entit
3941

4042
public function supports(Request $request)
4143
{
42-
return 'app_login' === $request->attributes->get('_route')
44+
return self::LOGIN_ROUTE === $request->attributes->get('_route')
4345
&& $request->isMethod('POST');
4446
}
4547

@@ -108,6 +110,6 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
108110

109111
protected function getLoginUrl()
110112
{
111-
return $this->urlGenerator->generate('app_login');
113+
return $this->urlGenerator->generate(self::LOGIN_ROUTE);
112114
}
113115
}

0 commit comments

Comments
 (0)