Skip to content

Commit 6b8526c

Browse files
committed
minor #16927 [Security] use a consistent route name for the login form (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Security] use a consistent route name for the login form fixes #16921 Commits ------- 240aeb5 use a consistent route name for the login form
2 parents cfa7597 + 240aeb5 commit 6b8526c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

security.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ First, create a controller for the login form:
683683
684684
class LoginController extends AbstractController
685685
{
686-
#[Route('/login', name: 'login')]
686+
#[Route('/login', name: 'app_login')]
687687
public function index(): Response
688688
{
689689
return $this->render('login/index.html.twig', [
@@ -706,9 +706,9 @@ Then, enable the form login authenticator using the ``form_login`` setting:
706706
main:
707707
# ...
708708
form_login:
709-
# "login" is the name of the route created previously
710-
login_path: login
711-
check_path: login
709+
# "app_login" is the name of the route created previously
710+
login_path: app_login
711+
check_path: app_login
712712
713713
.. code-block:: xml
714714
@@ -725,8 +725,8 @@ Then, enable the form login authenticator using the ``form_login`` setting:
725725
<config>
726726
<!-- ... -->
727727
<firewall name="main">
728-
<!-- "login" is the name of the route created previously -->
729-
<form-login login-path="login" check-path="login"/>
728+
<!-- "app_login" is the name of the route created previously -->
729+
<form-login login-path="app_login" check-path="app_login"/>
730730
</firewall>
731731
</config>
732732
</srv:container>
@@ -741,10 +741,10 @@ Then, enable the form login authenticator using the ``form_login`` setting:
741741
742742
$mainFirewall = $security->firewall('main');
743743
744-
// "login" is the name of the route created previously
744+
// "app_login" is the name of the route created previously
745745
$mainFirewall->formLogin()
746-
->loginPath('login')
747-
->checkPath('login')
746+
->loginPath('app_login')
747+
->checkPath('app_login')
748748
;
749749
};
750750
@@ -767,7 +767,7 @@ Edit the login controller to render the login form:
767767
768768
class LoginController extends AbstractController
769769
{
770-
#[Route('/login', name: 'login')]
770+
#[Route('/login', name: 'app_login')]
771771
- public function index(): Response
772772
+ public function index(AuthenticationUtils $authenticationUtils): Response
773773
{
@@ -805,7 +805,7 @@ Finally, create or update the template:
805805
<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
806806
{% endif %}
807807

808-
<form action="{{ path('login') }}" method="post">
808+
<form action="{{ path('app_login') }}" method="post">
809809
<label for="username">Email:</label>
810810
<input type="text" id="username" name="_username" value="{{ last_username }}"/>
811811

@@ -829,7 +829,7 @@ Finally, create or update the template:
829829

830830
The form can look like anything, but it usually follows some conventions:
831831

832-
* The ``<form>`` element sends a ``POST`` request to the ``login`` route, since
832+
* The ``<form>`` element sends a ``POST`` request to the ``app_login`` route, since
833833
that's what you configured as the ``check_path`` under the ``form_login`` key in
834834
``security.yaml``;
835835
* The username (or whatever your user's "identifier" is, like an email) field has
@@ -942,7 +942,7 @@ be ``authenticate``:
942942
{# templates/login/index.html.twig #}
943943

944944
{# ... #}
945-
<form action="{{ path('login') }}" method="post">
945+
<form action="{{ path('app_login') }}" method="post">
946946
{# ... the login fields #}
947947

948948
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">

0 commit comments

Comments
 (0)